Previous 15994 Revisions Next

r12757 Thursday 1st September, 2011 at 13:47:21 UTC by Miodrag Milanović
Final step, renaming file to i8251 and change remaining text (no whatsnew)
[src/mess]mess.mak
[src/mess/drivers]b2m.c einstein.c elwro800.c fk1.c irisha.c kyocera.c mbc55x.c nc.c pc6001.c pc8401a.c pmd85.c sage2.c sg1000.c sm1800.c tandy2k.c tsispch.c vixen.c votrpss.c xor100.c
[src/mess/includes]bw2.h cgc7900.h compis.h kyocera.h mbc55x.h pc8001.h pc8401a.h pk8020.h poly88.h px8.h v1050.h
[src/mess/machine]b2m.c i8251.c* i8251.h* irisha.c mbc55x.c msm8251.c msm8251.h nc.c pmd85.c rmnimbus.c serial.c

src/mess/machine/msm8251.c
r12756r12757
1/*********************************************************************
2
3    i8251.c
4
5   Intel 8251 Universal Synchronous/Asynchronous Receiver Transmitter code
6
7*********************************************************************/
8
9#include "emu.h"
10#include "msm8251.h"
11
12
13/***************************************************************************
14    MACROS
15***************************************************************************/
16
17#define VERBOSE 0
18
19#define LOG(x)   do { if (VERBOSE) logerror x; } while (0)
20
21/***************************************************************************
22    PROTOTYPES
23***************************************************************************/
24
25static void i8251_in_callback(running_machine &machine, int id, unsigned long state);
26
27/***************************************************************************
28    GLOBAL VARIABLES
29***************************************************************************/
30
31const i8251_interface default_i8251_interface = { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL };
32
33
34/***************************************************************************
35    IMPLEMENTATION
36***************************************************************************/
37
38/*-------------------------------------------------
39    i8251_in_callback
40-------------------------------------------------*/
41
42static void i8251_in_callback(running_machine &machine, int id, unsigned long state)
43{
44   int changed;
45
46   /* NPW 29-Nov-2008 - These two lines are a hack and indicate why our "serial" infrastructure needs to be updated */
47   i8251_device *device = machine.device<i8251_device>("uart");
48   
49
50   changed = device->get_connection()->input_state^state;
51
52   device->get_connection()->input_state = state;
53
54   /* did cts change state? */
55   if (changed & SERIAL_STATE_CTS)
56   {
57      /* yes */
58      /* update tx ready */
59      /* update_tx_ready(); */
60   }
61}
62
63//**************************************************************************
64//  DEVICE DEFINITIONS
65//**************************************************************************
66
67const device_type I8251 = &device_creator<i8251_device>;
68
69//-------------------------------------------------
70//  i8251_device - constructor
71//-------------------------------------------------
72
73i8251_device::i8251_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
74    : device_t(mconfig, I8251, "I8251", tag, owner, clock)
75{
76}
77
78//-------------------------------------------------
79//  device_config_complete - perform any
80//  operations now that the configuration is
81//  complete
82//-------------------------------------------------
83
84void i8251_device::device_config_complete()
85{
86   // inherit a copy of the static data
87   const i8251_interface *intf = reinterpret_cast<const i8251_interface *>(static_config());
88   if (intf != NULL)
89      *static_cast<i8251_interface *>(this) = *intf;
90
91   // or initialize to defaults if none provided
92   else
93   {
94      memset(&m_in_rxd_cb, 0, sizeof(m_in_rxd_cb));
95      memset(&m_out_txd_cb, 0, sizeof(m_out_txd_cb));
96      memset(&m_in_dsr_cb, 0, sizeof(m_in_dsr_cb));
97      memset(&m_out_dtr_cb, 0, sizeof(m_out_dtr_cb));
98      memset(&m_out_rts_cb, 0, sizeof(m_out_rts_cb));
99      memset(&m_out_rxrdy_cb, 0, sizeof(m_out_rxrdy_cb));
100      memset(&m_out_txrdy_cb, 0, sizeof(m_out_txrdy_cb));
101      memset(&m_out_txempty_cb, 0, sizeof(m_out_txempty_cb));
102      memset(&m_out_syndet_cb, 0, sizeof(m_out_syndet_cb));
103   }
104}
105
106//-------------------------------------------------
107//  device_start - device-specific startup
108//-------------------------------------------------
109
110void i8251_device::device_start()
111{
112   serial_helper_setup();
113
114   // resolve callbacks
115   m_out_rxrdy_func.resolve(m_out_rxrdy_cb, *this);
116   m_out_txrdy_func.resolve(m_out_txrdy_cb, *this);
117   m_out_txempty_func.resolve(m_out_txempty_cb, *this);
118
119   /* setup this side of the serial connection */
120   serial_connection_init(machine(),&m_connection);
121   serial_connection_set_in_callback(machine(),&m_connection, i8251_in_callback);
122   m_connection.input_state = 0;
123}
124
125
126
127
128/*-------------------------------------------------
129    update_rx_ready
130-------------------------------------------------*/
131
132void i8251_device::update_rx_ready()
133{
134   int state;
135
136   state = m_status & I8251_STATUS_RX_READY;
137
138   /* masked? */
139   if ((m_command & (1<<2))==0)
140   {
141      state = 0;
142   }
143
144   m_out_rxrdy_func(state != 0);
145}
146
147
148
149/*-------------------------------------------------
150    receive_clock
151-------------------------------------------------*/
152
153void i8251_device::receive_clock()
154{
155   /* receive enable? */
156   if (m_command & (1<<2))
157   {
158      //logerror("I8251\n");
159      /* get bit received from other side and update receive register */
160      receive_register_update_bit(&m_receive_reg, get_in_data_bit(m_connection.input_state));
161
162      if (m_receive_reg.flags & RECEIVE_REGISTER_FULL)
163      {
164         receive_register_extract(&m_receive_reg, &m_form);
165         receive_character(m_receive_reg.byte_received);
166      }
167   }
168}
169
170
171
172/*-------------------------------------------------
173    transmit_clock
174-------------------------------------------------*/
175
176void i8251_device::transmit_clock()
177{
178   /* transmit enable? */
179   if (m_command & (1<<0))
180   {
181
182      /* transmit register full? */
183      if ((m_status & I8251_STATUS_TX_READY)==0)
184      {
185         /* if transmit reg is empty */
186         if ((m_transmit_reg.flags & TRANSMIT_REGISTER_EMPTY)!=0)
187         {
188            /* set it up */
189            transmit_register_setup(&m_transmit_reg, &m_form, m_data);
190            /* i8251 transmit reg now empty */
191            m_status |=I8251_STATUS_TX_EMPTY;
192            /* ready for next transmit */
193            m_status |=I8251_STATUS_TX_READY;
194
195            update_tx_empty();
196            update_tx_ready();
197         }
198      }
199
200      /* if transmit is not empty... transmit data */
201      if ((m_transmit_reg.flags & TRANSMIT_REGISTER_EMPTY)==0)
202      {
203   //      logerror("I8251\n");
204         transmit_register_send_bit(machine(),&m_transmit_reg, &m_connection);
205      }
206   }
207
208#if 0
209   /* hunt mode? */
210   /* after each bit has been shifted in, it is compared against the current sync byte */
211   if (m_command & (1<<7))
212   {
213      /* data matches sync byte? */
214      if (m_data == m_sync_bytes[m_sync_byte_offset])
215      {
216         /* sync byte matches */
217         /* update for next sync byte? */
218         m_sync_byte_offset++;
219
220         /* do all sync bytes match? */
221         if (m_sync_byte_offset == m_sync_byte_count)
222         {
223            /* ent hunt mode */
224            m_command &=~(1<<7);
225         }
226      }
227      else
228      {
229         /* if there is no match, reset */
230         m_sync_byte_offset = 0;
231      }
232   }
233#endif
234}
235
236
237
238/*-------------------------------------------------
239    update_tx_ready
240-------------------------------------------------*/
241
242void i8251_device::update_tx_ready()
243{
244   /* clear tx ready state */
245   int tx_ready;
246
247   /* tx ready output is set if:
248        DB Buffer Empty &
249        CTS is set &
250        Transmit enable is 1
251    */
252
253   tx_ready = 0;
254
255   /* transmit enable? */
256   if ((m_command & (1<<0))!=0)
257   {
258      /* other side has rts set (comes in as CTS at this side) */
259      if (m_connection.input_state & SERIAL_STATE_CTS)
260      {
261         if (m_status & I8251_STATUS_TX_EMPTY)
262         {
263            /* enable transfer */
264            tx_ready = 1;
265         }
266      }
267   }
268
269   m_out_txrdy_func(tx_ready);
270}
271
272
273
274/*-------------------------------------------------
275    update_tx_empty
276-------------------------------------------------*/
277
278void i8251_device::update_tx_empty()
279{
280   if (m_status & I8251_STATUS_TX_EMPTY)
281   {
282      /* tx is in marking state (high) when tx empty! */
283      set_out_data_bit(m_connection.State, 1);
284      serial_connection_out(machine(),&m_connection);
285   }
286
287   m_out_txempty_func((m_status & I8251_STATUS_TX_EMPTY) != 0);
288}
289
290
291
292//-------------------------------------------------
293//  device_reset - device-specific reset
294//-------------------------------------------------
295
296void i8251_device::device_reset()
297{
298   LOG(("I8251: Reset\n"));
299
300   /* what is the default setup when the 8251 has been reset??? */
301
302   /* i8251 datasheet explains the state of tx pin at reset */
303   /* tx is set to 1 */
304   set_out_data_bit(m_connection.State,1);
305
306   /* assumption, rts is set to 1 */
307   m_connection.State &= ~SERIAL_STATE_RTS;
308   serial_connection_out(machine(), &m_connection);
309
310   transmit_register_reset(&m_transmit_reg);
311   receive_register_reset(&m_receive_reg);
312   /* expecting mode byte */
313   m_flags |= I8251_EXPECTING_MODE;
314   /* not expecting a sync byte */
315   m_flags &= ~I8251_EXPECTING_SYNC_BYTE;
316
317   /* no character to read by cpu */
318   /* transmitter is ready and is empty */
319   m_status = I8251_STATUS_TX_EMPTY | I8251_STATUS_TX_READY;
320   m_mode_byte = 0;
321   m_command = 0;
322
323   /* update tx empty pin output */
324   update_tx_empty();
325   /* update rx ready pin output */
326   update_rx_ready();
327   /* update tx ready pin output */
328   update_tx_ready();
329}
330
331
332
333/*-------------------------------------------------
334    control_w
335-------------------------------------------------*/
336
337WRITE8_MEMBER(i8251_device::control_w)
338{
339   if (m_flags & I8251_EXPECTING_MODE)
340   {
341      if (m_flags & I8251_EXPECTING_SYNC_BYTE)
342      {
343         LOG(("I8251: Sync byte\n"));
344
345         LOG(("Sync byte: %02x\n", data));
346         /* store sync byte written */
347         m_sync_bytes[m_sync_byte_offset] = data;
348         m_sync_byte_offset++;
349
350         if (m_sync_byte_offset == m_sync_byte_count)
351         {
352            /* finished transfering sync bytes, now expecting command */
353            m_flags &= ~(I8251_EXPECTING_MODE | I8251_EXPECTING_SYNC_BYTE);
354            m_sync_byte_offset = 0;
355         //  m_status = I8251_STATUS_TX_EMPTY | I8251_STATUS_TX_READY;
356         }
357      }
358      else
359      {
360         LOG(("I8251: Mode byte\n"));
361
362         m_mode_byte = data;
363
364         /* Synchronous or Asynchronous? */
365         if ((data & 0x03)!=0)
366         {
367            /*  Asynchronous
368
369                    bit 7,6: stop bit length
370                        0 = inhibit
371                        1 = 1 bit
372                        2 = 1.5 bits
373                        3 = 2 bits
374                    bit 5: parity type
375                        0 = parity odd
376                        1 = parity even
377                    bit 4: parity test enable
378                        0 = disable
379                        1 = enable
380                    bit 3,2: character length
381                        0 = 5 bits
382                        1 = 6 bits
383                        2 = 7 bits
384                        3 = 8 bits
385                    bit 1,0: baud rate factor
386                        0 = defines command byte for synchronous or asynchronous
387                        1 = x1
388                        2 = x16
389                        3 = x64
390                */
391
392            LOG(("I8251: Asynchronous operation\n"));
393
394            LOG(("Character length: %d\n", (((data>>2) & 0x03)+5)));
395
396            if (data & (1<<4))
397            {
398               LOG(("enable parity checking\n"));
399            }
400            else
401            {
402               LOG(("parity check disabled\n"));
403            }
404
405            if (data & (1<<5))
406            {
407               LOG(("even parity\n"));
408            }
409            else
410            {
411               LOG(("odd parity\n"));
412            }
413
414            {
415               UINT8 stop_bit_length;
416
417               stop_bit_length = (data>>6) & 0x03;
418
419               switch (stop_bit_length)
420               {
421                  case 0:
422                  {
423                     /* inhibit */
424                     LOG(("stop bit: inhibit\n"));
425                  }
426                  break;
427
428                  case 1:
429                  {
430                     /* 1 */
431                     LOG(("stop bit: 1 bit\n"));
432                  }
433                  break;
434
435                  case 2:
436                  {
437                     /* 1.5 */
438                     LOG(("stop bit: 1.5 bits\n"));
439                  }
440                  break;
441
442                  case 3:
443                  {
444                     /* 2 */
445                     LOG(("stop bit: 2 bits\n"));
446                  }
447                  break;
448               }
449            }
450
451            m_form.word_length = ((data>>2) & 0x03)+5;
452            m_form.parity = SERIAL_PARITY_NONE;
453            switch ((data>>6) & 0x03)
454            {
455               case 0:
456               case 1:
457                  m_form.stop_bit_count =  1;
458                  break;
459               case 2:
460               case 3:
461                  m_form.stop_bit_count =  2;
462                  break;
463            }
464            receive_register_setup(&m_receive_reg, &m_form);
465
466
467#if 0
468            /* data bits */
469            m_receive_char_length = (((data>>2) & 0x03)+5);
470
471            if (data & (1<<4))
472            {
473               /* parity */
474               m_receive_char_length++;
475            }
476
477            /* stop bits */
478            m_receive_char_length++;
479
480            m_receive_flags &=~I8251_TRANSFER_RECEIVE_SYNCHRONISED;
481            m_receive_flags |= I8251_TRANSFER_RECEIVE_WAITING_FOR_START_BIT;
482#endif
483            /* not expecting mode byte now */
484            m_flags &= ~I8251_EXPECTING_MODE;
485//              m_status = I8251_STATUS_TX_EMPTY | I8251_STATUS_TX_READY;
486         }
487         else
488         {
489            /*  bit 7: Number of sync characters
490                        0 = 1 character
491                        1 = 2 character
492                    bit 6: Synchronous mode
493                        0 = Internal synchronisation
494                        1 = External synchronisation
495                    bit 5: parity type
496                        0 = parity odd
497                        1 = parity even
498                    bit 4: parity test enable
499                        0 = disable
500                        1 = enable
501                    bit 3,2: character length
502                        0 = 5 bits
503                        1 = 6 bits
504                        2 = 7 bits
505                        3 = 8 bits
506                    bit 1,0 = 0
507                */
508            LOG(("I8251: Synchronous operation\n"));
509
510            /* setup for sync byte(s) */
511            m_flags |= I8251_EXPECTING_SYNC_BYTE;
512            m_sync_byte_offset = 0;
513            if (data & 0x07)
514            {
515               m_sync_byte_count = 1;
516            }
517            else
518            {
519               m_sync_byte_count = 2;
520            }
521
522         }
523      }
524   }
525   else
526   {
527      /* command */
528      LOG(("I8251: Command byte\n"));
529
530      m_command = data;
531
532      LOG(("Command byte: %02x\n", data));
533
534      if (data & (1<<7))
535      {
536         LOG(("hunt mode\n"));
537      }
538
539      if (data & (1<<5))
540      {
541         LOG(("/rts set to 0\n"));
542      }
543      else
544      {
545         LOG(("/rts set to 1\n"));
546      }
547
548      if (data & (1<<2))
549      {
550         LOG(("receive enable\n"));
551      }
552      else
553      {
554         LOG(("receive disable\n"));
555      }
556
557      if (data & (1<<1))
558      {
559         LOG(("/dtr set to 0\n"));
560      }
561      else
562      {
563         LOG(("/dtr set to 1\n"));
564      }
565
566      if (data & (1<<0))
567      {
568         LOG(("transmit enable\n"));
569      }
570      else
571      {
572         LOG(("transmit disable\n"));
573      }
574
575
576      /*  bit 7:
577                0 = normal operation
578                1 = hunt mode
579            bit 6:
580                0 = normal operation
581                1 = internal reset
582            bit 5:
583                0 = /RTS set to 1
584                1 = /RTS set to 0
585            bit 4:
586                0 = normal operation
587                1 = reset error flag
588            bit 3:
589                0 = normal operation
590                1 = send break character
591            bit 2:
592                0 = receive disable
593                1 = receive enable
594            bit 1:
595                0 = /DTR set to 1
596                1 = /DTR set to 0
597            bit 0:
598                0 = transmit disable
599                1 = transmit enable
600        */
601
602      m_connection.State &=~SERIAL_STATE_RTS;
603      if (data & (1<<5))
604      {
605         /* rts set to 0 */
606         m_connection.State |= SERIAL_STATE_RTS;
607      }
608
609      m_connection.State &=~SERIAL_STATE_DTR;
610      if (data & (1<<1))
611      {
612         m_connection.State |= SERIAL_STATE_DTR;
613      }
614
615      if ((data & (1<<0))==0)
616      {
617         /* held in high state when transmit disable */
618         set_out_data_bit(m_connection.State,1);
619      }
620
621
622      /* refresh outputs */
623      serial_connection_out(machine(), &m_connection);
624
625      if (data & (1<<4))
626      {
627         m_status &= ~(I8251_STATUS_PARITY_ERROR | I8251_STATUS_OVERRUN_ERROR | I8251_STATUS_FRAMING_ERROR);
628      }
629
630      if (data & (1<<6))
631      {
632         reset();
633      }
634
635      update_rx_ready();
636      update_tx_ready();
637
638   }
639}
640
641
642
643/*-------------------------------------------------
644    status_r
645-------------------------------------------------*/
646
647READ8_MEMBER(i8251_device::status_r)
648{
649   LOG(("status: %02x\n", m_status));
650   return m_status;
651}
652
653
654
655/*-------------------------------------------------
656    data_w
657-------------------------------------------------*/
658
659WRITE8_MEMBER(i8251_device::data_w)
660{
661   m_data = data;
662
663   logerror("write data: %02x\n",data);
664
665   /* writing clears */
666   m_status &=~I8251_STATUS_TX_READY;
667
668   /* if transmitter is active, then tx empty will be signalled */
669
670   update_tx_ready();
671}
672
673
674
675/*-------------------------------------------------
676    receive_character - called when last
677    bit of data has been received
678-------------------------------------------------*/
679
680void i8251_device::receive_character(UINT8 ch)
681{
682   logerror("i8251 receive char: %02x\n",ch);
683
684   m_data = ch;
685
686   /* char has not been read and another has arrived! */
687   if (m_status & I8251_STATUS_RX_READY)
688   {
689      m_status |= I8251_STATUS_OVERRUN_ERROR;
690   }
691   m_status |= I8251_STATUS_RX_READY;
692
693   update_rx_ready();
694}
695
696
697
698/*-------------------------------------------------
699    data_r - read data
700-------------------------------------------------*/
701
702READ8_MEMBER(i8251_device::data_r)
703{
704   logerror("read data: %02x, STATUS=%02x\n",m_data,m_status);
705   /* reading clears */
706   m_status &= ~I8251_STATUS_RX_READY;
707
708   update_rx_ready();
709   return m_data;
710}
711
712
713
714/*-------------------------------------------------
715    connect_to_serial_device - initialise
716    transfer using serial device - set the callback
717    which will be called when serial device has
718    updated it's state
719-------------------------------------------------*/
720
721void i8251_device::connect_to_serial_device(device_t *image)
722{
723   serial_device_connect(image, &m_connection);
724}
725
726
727
728/*-------------------------------------------------
729    connect
730-------------------------------------------------*/
731
732void i8251_device::connect(serial_connection *other_connection)
733{
734   serial_connection_link(machine(), &m_connection, other_connection);
735}
src/mess/machine/msm8251.h
r12756r12757
1/*********************************************************************
2
3    i8251.h
4
5    Intel 8251 Universal Synchronous/Asynchronous Receiver Transmitter code
6
7*********************************************************************/
8
9#ifndef __I8251_H__
10#define __I8251_H__
11
12#include "machine/serial.h"
13
14
15/***************************************************************************
16    CONSTANTS
17***************************************************************************/
18
19#define I8251_EXPECTING_MODE 0x01
20#define I8251_EXPECTING_SYNC_BYTE 0x02
21
22#define I8251_STATUS_FRAMING_ERROR 0x020
23#define I8251_STATUS_OVERRUN_ERROR 0x010
24#define I8251_STATUS_PARITY_ERROR 0x08
25#define I8251_STATUS_TX_EMPTY      0x04
26#define I8251_STATUS_RX_READY   0x02
27#define I8251_STATUS_TX_READY   0x01
28
29//**************************************************************************
30//  INTERFACE CONFIGURATION MACROS
31//**************************************************************************
32
33#define MCFG_I8251_ADD(_tag, _intrf) \
34   MCFG_DEVICE_ADD(_tag, I8251, 0) \
35   MCFG_DEVICE_CONFIG(_intrf)
36
37#define MCFG_I8251_REMOVE(_tag) \
38   MCFG_DEVICE_REMOVE(_tag)
39
40
41/***************************************************************************
42    TYPE DEFINITIONS
43***************************************************************************/
44// ======================> i8251_interface
45
46struct i8251_interface
47{
48   devcb_read_line      m_in_rxd_cb;
49   devcb_write_line   m_out_txd_cb;
50   devcb_read_line      m_in_dsr_cb;
51   devcb_write_line   m_out_dtr_cb;
52   devcb_write_line   m_out_rts_cb;
53   devcb_write_line   m_out_rxrdy_cb;
54   devcb_write_line   m_out_txrdy_cb;
55   devcb_write_line   m_out_txempty_cb;
56   devcb_write_line   m_out_syndet_cb;
57};
58
59// ======================> i8251_device
60
61class i8251_device :  public device_t,
62                 public i8251_interface
63{
64public:
65    // construction/destruction
66    i8251_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
67
68   /* read data register */
69   DECLARE_READ8_MEMBER(data_r);
70
71   /* read status register */
72   DECLARE_READ8_MEMBER(status_r);
73
74   /* write data register */
75   DECLARE_WRITE8_MEMBER(data_w);
76
77   /* write control word */
78   DECLARE_WRITE8_MEMBER(control_w);
79
80   /* The 8251 has seperate transmit and receive clocks */
81   /* use these two functions to update the i8251 for each clock */
82   /* on NC100 system, the clocks are the same */
83   void transmit_clock();
84   void receive_clock();
85
86   /* connecting to serial output */
87   void connect_to_serial_device(device_t *image);
88   void connect(serial_connection *other_connection);
89
90   void receive_character(UINT8 ch);
91   
92   serial_connection *get_connection() { return &m_connection; }
93protected:
94    // device-level overrides
95    virtual void device_start();
96   virtual void device_config_complete();
97   virtual void device_reset();
98
99   void update_rx_ready();
100   void update_tx_ready();
101   void update_tx_empty();
102private:
103   devcb_resolved_read_line   m_in_rxd_func;
104   devcb_resolved_write_line   m_out_txd_func;
105   devcb_resolved_read_line   m_in_dsr_func;
106   devcb_resolved_write_line   m_out_dtr_func;
107   devcb_resolved_write_line   m_out_rts_func;
108   devcb_resolved_write_line   m_out_rxrdy_func;
109   devcb_resolved_write_line   m_out_txrdy_func;
110   devcb_resolved_write_line   m_out_txempty_func;
111   devcb_resolved_write_line   m_out_syndet_func;
112
113   /* flags controlling how i8251_control_w operates */
114   UINT8 m_flags;
115   /* offset into sync_bytes used during sync byte transfer */
116   UINT8 m_sync_byte_offset;
117   /* number of sync bytes written so far */
118   UINT8 m_sync_byte_count;
119   /* the sync bytes written */
120   UINT8 m_sync_bytes[2];
121   /* status of i8251 */
122   UINT8 m_status;
123   UINT8 m_command;
124   /* mode byte - bit definitions depend on mode - e.g. synchronous, asynchronous */
125   UINT8 m_mode_byte;
126
127   /* data being received */
128   UINT8 m_data;
129
130   /* receive reg */
131   serial_receive_register m_receive_reg;
132   /* transmit reg */
133   serial_transmit_register m_transmit_reg;
134
135   data_form m_form;
136
137   /* the serial connection that data is transfered over */
138   /* this is usually connected to the serial device */
139   serial_connection m_connection;   
140};
141
142
143
144// device type definition
145extern const device_type I8251;
146
147/***************************************************************************
148    PROTOTYPES
149***************************************************************************/
150
151extern const i8251_interface default_i8251_interface;
152
153#endif /* __I8251_H__ */
src/mess/machine/serial.c
r12756r12757
1313    This therefore signals that data is following.
1414    When all data bits have been received, stop bits are transmitted with a value of 1.
1515
16    msm8251 expects this in asynchronous mode:
16    i8251 expects this in asynchronous mode:
1717    packet format:
1818
1919    bit count           function        value
src/mess/machine/b2m.c
r12756r12757
1414#include "machine/pit8253.h"
1515#include "machine/wd17xx.h"
1616#include "machine/pic8259.h"
17#include "machine/msm8251.h"
17#include "machine/i8251.h"
1818#include "includes/b2m.h"
1919#include "machine/ram.h"
2020#include "imagedev/flopdrv.h"
src/mess/machine/pmd85.c
r12756r12757
1414#include "cpu/i8085/i8085.h"
1515#include "machine/i8255.h"
1616#include "includes/pmd85.h"
17#include "machine/msm8251.h"
17#include "machine/i8251.h"
1818#include "machine/pit8253.h"
1919#include "machine/ram.h"
2020
r12756r12757
419419        CLK0    - external interfaces connector (K2)
420420        GATE0   - external interfaces connector (K2), default = 1
421421    Timer 1:
422        OUT0    - external interfaces connector (K2), msm8251 (for V24 only)
422        OUT0    - external interfaces connector (K2), i8251 (for V24 only)
423423        CLK0    - hardwired to 2 MHz system clock
424424        GATE0   - external interfaces connector (K2), default = 1
425425    Timer 2:
src/mess/machine/i8251.c
r0r12757
1/*********************************************************************
2
3    i8251.c
4
5   Intel 8251 Universal Synchronous/Asynchronous Receiver Transmitter code
6
7*********************************************************************/
8
9#include "emu.h"
10#include "i8251.h"
11
12
13/***************************************************************************
14    MACROS
15***************************************************************************/
16
17#define VERBOSE 0
18
19#define LOG(x)   do { if (VERBOSE) logerror x; } while (0)
20
21/***************************************************************************
22    PROTOTYPES
23***************************************************************************/
24
25static void i8251_in_callback(running_machine &machine, int id, unsigned long state);
26
27/***************************************************************************
28    GLOBAL VARIABLES
29***************************************************************************/
30
31const i8251_interface default_i8251_interface = { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL };
32
33
34/***************************************************************************
35    IMPLEMENTATION
36***************************************************************************/
37
38/*-------------------------------------------------
39    i8251_in_callback
40-------------------------------------------------*/
41
42static void i8251_in_callback(running_machine &machine, int id, unsigned long state)
43{
44   int changed;
45
46   /* NPW 29-Nov-2008 - These two lines are a hack and indicate why our "serial" infrastructure needs to be updated */
47   i8251_device *device = machine.device<i8251_device>("uart");
48   
49
50   changed = device->get_connection()->input_state^state;
51
52   device->get_connection()->input_state = state;
53
54   /* did cts change state? */
55   if (changed & SERIAL_STATE_CTS)
56   {
57      /* yes */
58      /* update tx ready */
59      /* update_tx_ready(); */
60   }
61}
62
63//**************************************************************************
64//  DEVICE DEFINITIONS
65//**************************************************************************
66
67const device_type I8251 = &device_creator<i8251_device>;
68
69//-------------------------------------------------
70//  i8251_device - constructor
71//-------------------------------------------------
72
73i8251_device::i8251_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
74    : device_t(mconfig, I8251, "I8251", tag, owner, clock)
75{
76}
77
78//-------------------------------------------------
79//  device_config_complete - perform any
80//  operations now that the configuration is
81//  complete
82//-------------------------------------------------
83
84void i8251_device::device_config_complete()
85{
86   // inherit a copy of the static data
87   const i8251_interface *intf = reinterpret_cast<const i8251_interface *>(static_config());
88   if (intf != NULL)
89      *static_cast<i8251_interface *>(this) = *intf;
90
91   // or initialize to defaults if none provided
92   else
93   {
94      memset(&m_in_rxd_cb, 0, sizeof(m_in_rxd_cb));
95      memset(&m_out_txd_cb, 0, sizeof(m_out_txd_cb));
96      memset(&m_in_dsr_cb, 0, sizeof(m_in_dsr_cb));
97      memset(&m_out_dtr_cb, 0, sizeof(m_out_dtr_cb));
98      memset(&m_out_rts_cb, 0, sizeof(m_out_rts_cb));
99      memset(&m_out_rxrdy_cb, 0, sizeof(m_out_rxrdy_cb));
100      memset(&m_out_txrdy_cb, 0, sizeof(m_out_txrdy_cb));
101      memset(&m_out_txempty_cb, 0, sizeof(m_out_txempty_cb));
102      memset(&m_out_syndet_cb, 0, sizeof(m_out_syndet_cb));
103   }
104}
105
106//-------------------------------------------------
107//  device_start - device-specific startup
108//-------------------------------------------------
109
110void i8251_device::device_start()
111{
112   serial_helper_setup();
113
114   // resolve callbacks
115   m_out_rxrdy_func.resolve(m_out_rxrdy_cb, *this);
116   m_out_txrdy_func.resolve(m_out_txrdy_cb, *this);
117   m_out_txempty_func.resolve(m_out_txempty_cb, *this);
118
119   /* setup this side of the serial connection */
120   serial_connection_init(machine(),&m_connection);
121   serial_connection_set_in_callback(machine(),&m_connection, i8251_in_callback);
122   m_connection.input_state = 0;
123}
124
125
126
127
128/*-------------------------------------------------
129    update_rx_ready
130-------------------------------------------------*/
131
132void i8251_device::update_rx_ready()
133{
134   int state;
135
136   state = m_status & I8251_STATUS_RX_READY;
137
138   /* masked? */
139   if ((m_command & (1<<2))==0)
140   {
141      state = 0;
142   }
143
144   m_out_rxrdy_func(state != 0);
145}
146
147
148
149/*-------------------------------------------------
150    receive_clock
151-------------------------------------------------*/
152
153void i8251_device::receive_clock()
154{
155   /* receive enable? */
156   if (m_command & (1<<2))
157   {
158      //logerror("I8251\n");
159      /* get bit received from other side and update receive register */
160      receive_register_update_bit(&m_receive_reg, get_in_data_bit(m_connection.input_state));
161
162      if (m_receive_reg.flags & RECEIVE_REGISTER_FULL)
163      {
164         receive_register_extract(&m_receive_reg, &m_form);
165         receive_character(m_receive_reg.byte_received);
166      }
167   }
168}
169
170
171
172/*-------------------------------------------------
173    transmit_clock
174-------------------------------------------------*/
175
176void i8251_device::transmit_clock()
177{
178   /* transmit enable? */
179   if (m_command & (1<<0))
180   {
181
182      /* transmit register full? */
183      if ((m_status & I8251_STATUS_TX_READY)==0)
184      {
185         /* if transmit reg is empty */
186         if ((m_transmit_reg.flags & TRANSMIT_REGISTER_EMPTY)!=0)
187         {
188            /* set it up */
189            transmit_register_setup(&m_transmit_reg, &m_form, m_data);
190            /* i8251 transmit reg now empty */
191            m_status |=I8251_STATUS_TX_EMPTY;
192            /* ready for next transmit */
193            m_status |=I8251_STATUS_TX_READY;
194
195            update_tx_empty();
196            update_tx_ready();
197         }
198      }
199
200      /* if transmit is not empty... transmit data */
201      if ((m_transmit_reg.flags & TRANSMIT_REGISTER_EMPTY)==0)
202      {
203   //      logerror("I8251\n");
204         transmit_register_send_bit(machine(),&m_transmit_reg, &m_connection);
205      }
206   }
207
208#if 0
209   /* hunt mode? */
210   /* after each bit has been shifted in, it is compared against the current sync byte */
211   if (m_command & (1<<7))
212   {
213      /* data matches sync byte? */
214      if (m_data == m_sync_bytes[m_sync_byte_offset])
215      {
216         /* sync byte matches */
217         /* update for next sync byte? */
218         m_sync_byte_offset++;
219
220         /* do all sync bytes match? */
221         if (m_sync_byte_offset == m_sync_byte_count)
222         {
223            /* ent hunt mode */
224            m_command &=~(1<<7);
225         }
226      }
227      else
228      {
229         /* if there is no match, reset */
230         m_sync_byte_offset = 0;
231      }
232   }
233#endif
234}
235
236
237
238/*-------------------------------------------------
239    update_tx_ready
240-------------------------------------------------*/
241
242void i8251_device::update_tx_ready()
243{
244   /* clear tx ready state */
245   int tx_ready;
246
247   /* tx ready output is set if:
248        DB Buffer Empty &
249        CTS is set &
250        Transmit enable is 1
251    */
252
253   tx_ready = 0;
254
255   /* transmit enable? */
256   if ((m_command & (1<<0))!=0)
257   {
258      /* other side has rts set (comes in as CTS at this side) */
259      if (m_connection.input_state & SERIAL_STATE_CTS)
260      {
261         if (m_status & I8251_STATUS_TX_EMPTY)
262         {
263            /* enable transfer */
264            tx_ready = 1;
265         }
266      }
267   }
268
269   m_out_txrdy_func(tx_ready);
270}
271
272
273
274/*-------------------------------------------------
275    update_tx_empty
276-------------------------------------------------*/
277
278void i8251_device::update_tx_empty()
279{
280   if (m_status & I8251_STATUS_TX_EMPTY)
281   {
282      /* tx is in marking state (high) when tx empty! */
283      set_out_data_bit(m_connection.State, 1);
284      serial_connection_out(machine(),&m_connection);
285   }
286
287   m_out_txempty_func((m_status & I8251_STATUS_TX_EMPTY) != 0);
288}
289
290
291
292//-------------------------------------------------
293//  device_reset - device-specific reset
294//-------------------------------------------------
295
296void i8251_device::device_reset()
297{
298   LOG(("I8251: Reset\n"));
299
300   /* what is the default setup when the 8251 has been reset??? */
301
302   /* i8251 datasheet explains the state of tx pin at reset */
303   /* tx is set to 1 */
304   set_out_data_bit(m_connection.State,1);
305
306   /* assumption, rts is set to 1 */
307   m_connection.State &= ~SERIAL_STATE_RTS;
308   serial_connection_out(machine(), &m_connection);
309
310   transmit_register_reset(&m_transmit_reg);
311   receive_register_reset(&m_receive_reg);
312   /* expecting mode byte */
313   m_flags |= I8251_EXPECTING_MODE;
314   /* not expecting a sync byte */
315   m_flags &= ~I8251_EXPECTING_SYNC_BYTE;
316
317   /* no character to read by cpu */
318   /* transmitter is ready and is empty */
319   m_status = I8251_STATUS_TX_EMPTY | I8251_STATUS_TX_READY;
320   m_mode_byte = 0;
321   m_command = 0;
322
323   /* update tx empty pin output */
324   update_tx_empty();
325   /* update rx ready pin output */
326   update_rx_ready();
327   /* update tx ready pin output */
328   update_tx_ready();
329}
330
331
332
333/*-------------------------------------------------
334    control_w
335-------------------------------------------------*/
336
337WRITE8_MEMBER(i8251_device::control_w)
338{
339   if (m_flags & I8251_EXPECTING_MODE)
340   {
341      if (m_flags & I8251_EXPECTING_SYNC_BYTE)
342      {
343         LOG(("I8251: Sync byte\n"));
344
345         LOG(("Sync byte: %02x\n", data));
346         /* store sync byte written */
347         m_sync_bytes[m_sync_byte_offset] = data;
348         m_sync_byte_offset++;
349
350         if (m_sync_byte_offset == m_sync_byte_count)
351         {
352            /* finished transfering sync bytes, now expecting command */
353            m_flags &= ~(I8251_EXPECTING_MODE | I8251_EXPECTING_SYNC_BYTE);
354            m_sync_byte_offset = 0;
355         //  m_status = I8251_STATUS_TX_EMPTY | I8251_STATUS_TX_READY;
356         }
357      }
358      else
359      {
360         LOG(("I8251: Mode byte\n"));
361
362         m_mode_byte = data;
363
364         /* Synchronous or Asynchronous? */
365         if ((data & 0x03)!=0)
366         {
367            /*  Asynchronous
368
369                    bit 7,6: stop bit length
370                        0 = inhibit
371                        1 = 1 bit
372                        2 = 1.5 bits
373                        3 = 2 bits
374                    bit 5: parity type
375                        0 = parity odd
376                        1 = parity even
377                    bit 4: parity test enable
378                        0 = disable
379                        1 = enable
380                    bit 3,2: character length
381                        0 = 5 bits
382                        1 = 6 bits
383                        2 = 7 bits
384                        3 = 8 bits
385                    bit 1,0: baud rate factor
386                        0 = defines command byte for synchronous or asynchronous
387                        1 = x1
388                        2 = x16
389                        3 = x64
390                */
391
392            LOG(("I8251: Asynchronous operation\n"));
393
394            LOG(("Character length: %d\n", (((data>>2) & 0x03)+5)));
395
396            if (data & (1<<4))
397            {
398               LOG(("enable parity checking\n"));
399            }
400            else
401            {
402               LOG(("parity check disabled\n"));
403            }
404
405            if (data & (1<<5))
406            {
407               LOG(("even parity\n"));
408            }
409            else
410            {
411               LOG(("odd parity\n"));
412            }
413
414            {
415               UINT8 stop_bit_length;
416
417               stop_bit_length = (data>>6) & 0x03;
418
419               switch (stop_bit_length)
420               {
421                  case 0:
422                  {
423                     /* inhibit */
424                     LOG(("stop bit: inhibit\n"));
425                  }
426                  break;
427
428                  case 1:
429                  {
430                     /* 1 */
431                     LOG(("stop bit: 1 bit\n"));
432                  }
433                  break;
434
435                  case 2:
436                  {
437                     /* 1.5 */
438                     LOG(("stop bit: 1.5 bits\n"));
439                  }
440                  break;
441
442                  case 3:
443                  {
444                     /* 2 */
445                     LOG(("stop bit: 2 bits\n"));
446                  }
447                  break;
448               }
449            }
450
451            m_form.word_length = ((data>>2) & 0x03)+5;
452            m_form.parity = SERIAL_PARITY_NONE;
453            switch ((data>>6) & 0x03)
454            {
455               case 0:
456               case 1:
457                  m_form.stop_bit_count =  1;
458                  break;
459               case 2:
460               case 3:
461                  m_form.stop_bit_count =  2;
462                  break;
463            }
464            receive_register_setup(&m_receive_reg, &m_form);
465
466
467#if 0
468            /* data bits */
469            m_receive_char_length = (((data>>2) & 0x03)+5);
470
471            if (data & (1<<4))
472            {
473               /* parity */
474               m_receive_char_length++;
475            }
476
477            /* stop bits */
478            m_receive_char_length++;
479
480            m_receive_flags &=~I8251_TRANSFER_RECEIVE_SYNCHRONISED;
481            m_receive_flags |= I8251_TRANSFER_RECEIVE_WAITING_FOR_START_BIT;
482#endif
483            /* not expecting mode byte now */
484            m_flags &= ~I8251_EXPECTING_MODE;
485//              m_status = I8251_STATUS_TX_EMPTY | I8251_STATUS_TX_READY;
486         }
487         else
488         {
489            /*  bit 7: Number of sync characters
490                        0 = 1 character
491                        1 = 2 character
492                    bit 6: Synchronous mode
493                        0 = Internal synchronisation
494                        1 = External synchronisation
495                    bit 5: parity type
496                        0 = parity odd
497                        1 = parity even
498                    bit 4: parity test enable
499                        0 = disable
500                        1 = enable
501                    bit 3,2: character length
502                        0 = 5 bits
503                        1 = 6 bits
504                        2 = 7 bits
505                        3 = 8 bits
506                    bit 1,0 = 0
507                */
508            LOG(("I8251: Synchronous operation\n"));
509
510            /* setup for sync byte(s) */
511            m_flags |= I8251_EXPECTING_SYNC_BYTE;
512            m_sync_byte_offset = 0;
513            if (data & 0x07)
514            {
515               m_sync_byte_count = 1;
516            }
517            else
518            {
519               m_sync_byte_count = 2;
520            }
521
522         }
523      }
524   }
525   else
526   {
527      /* command */
528      LOG(("I8251: Command byte\n"));
529
530      m_command = data;
531
532      LOG(("Command byte: %02x\n", data));
533
534      if (data & (1<<7))
535      {
536         LOG(("hunt mode\n"));
537      }
538
539      if (data & (1<<5))
540      {
541         LOG(("/rts set to 0\n"));
542      }
543      else
544      {
545         LOG(("/rts set to 1\n"));
546      }
547
548      if (data & (1<<2))
549      {
550         LOG(("receive enable\n"));
551      }
552      else
553      {
554         LOG(("receive disable\n"));
555      }
556
557      if (data & (1<<1))
558      {
559         LOG(("/dtr set to 0\n"));
560      }
561      else
562      {
563         LOG(("/dtr set to 1\n"));
564      }
565
566      if (data & (1<<0))
567      {
568         LOG(("transmit enable\n"));
569      }
570      else
571      {
572         LOG(("transmit disable\n"));
573      }
574
575
576      /*  bit 7:
577                0 = normal operation
578                1 = hunt mode
579            bit 6:
580                0 = normal operation
581                1 = internal reset
582            bit 5:
583                0 = /RTS set to 1
584                1 = /RTS set to 0
585            bit 4:
586                0 = normal operation
587                1 = reset error flag
588            bit 3:
589                0 = normal operation
590                1 = send break character
591            bit 2:
592                0 = receive disable
593                1 = receive enable
594            bit 1:
595                0 = /DTR set to 1
596                1 = /DTR set to 0
597            bit 0:
598                0 = transmit disable
599                1 = transmit enable
600        */
601
602      m_connection.State &=~SERIAL_STATE_RTS;
603      if (data & (1<<5))
604      {
605         /* rts set to 0 */
606         m_connection.State |= SERIAL_STATE_RTS;
607      }
608
609      m_connection.State &=~SERIAL_STATE_DTR;
610      if (data & (1<<1))
611      {
612         m_connection.State |= SERIAL_STATE_DTR;
613      }
614
615      if ((data & (1<<0))==0)
616      {
617         /* held in high state when transmit disable */
618         set_out_data_bit(m_connection.State,1);
619      }
620
621
622      /* refresh outputs */
623      serial_connection_out(machine(), &m_connection);
624
625      if (data & (1<<4))
626      {
627         m_status &= ~(I8251_STATUS_PARITY_ERROR | I8251_STATUS_OVERRUN_ERROR | I8251_STATUS_FRAMING_ERROR);
628      }
629
630      if (data & (1<<6))
631      {
632         reset();
633      }
634
635      update_rx_ready();
636      update_tx_ready();
637
638   }
639}
640
641
642
643/*-------------------------------------------------
644    status_r
645-------------------------------------------------*/
646
647READ8_MEMBER(i8251_device::status_r)
648{
649   LOG(("status: %02x\n", m_status));
650   return m_status;
651}
652
653
654
655/*-------------------------------------------------
656    data_w
657-------------------------------------------------*/
658
659WRITE8_MEMBER(i8251_device::data_w)
660{
661   m_data = data;
662
663   logerror("write data: %02x\n",data);
664
665   /* writing clears */
666   m_status &=~I8251_STATUS_TX_READY;
667
668   /* if transmitter is active, then tx empty will be signalled */
669
670   update_tx_ready();
671}
672
673
674
675/*-------------------------------------------------
676    receive_character - called when last
677    bit of data has been received
678-------------------------------------------------*/
679
680void i8251_device::receive_character(UINT8 ch)
681{
682   logerror("i8251 receive char: %02x\n",ch);
683
684   m_data = ch;
685
686   /* char has not been read and another has arrived! */
687   if (m_status & I8251_STATUS_RX_READY)
688   {
689      m_status |= I8251_STATUS_OVERRUN_ERROR;
690   }
691   m_status |= I8251_STATUS_RX_READY;
692
693   update_rx_ready();
694}
695
696
697
698/*-------------------------------------------------
699    data_r - read data
700-------------------------------------------------*/
701
702READ8_MEMBER(i8251_device::data_r)
703{
704   logerror("read data: %02x, STATUS=%02x\n",m_data,m_status);
705   /* reading clears */
706   m_status &= ~I8251_STATUS_RX_READY;
707
708   update_rx_ready();
709   return m_data;
710}
711
712
713
714/*-------------------------------------------------
715    connect_to_serial_device - initialise
716    transfer using serial device - set the callback
717    which will be called when serial device has
718    updated it's state
719-------------------------------------------------*/
720
721void i8251_device::connect_to_serial_device(device_t *image)
722{
723   serial_device_connect(image, &m_connection);
724}
725
726
727
728/*-------------------------------------------------
729    connect
730-------------------------------------------------*/
731
732void i8251_device::connect(serial_connection *other_connection)
733{
734   serial_connection_link(machine(), &m_connection, other_connection);
735}
src/mess/machine/i8251.h
r0r12757
1/*********************************************************************
2
3    i8251.h
4
5    Intel 8251 Universal Synchronous/Asynchronous Receiver Transmitter code
6
7*********************************************************************/
8
9#ifndef __I8251_H__
10#define __I8251_H__
11
12#include "machine/serial.h"
13
14
15/***************************************************************************
16    CONSTANTS
17***************************************************************************/
18
19#define I8251_EXPECTING_MODE       0x01
20#define I8251_EXPECTING_SYNC_BYTE    0x02
21
22#define I8251_STATUS_FRAMING_ERROR    0x20
23#define I8251_STATUS_OVERRUN_ERROR    0x10
24#define I8251_STATUS_PARITY_ERROR    0x08
25#define I8251_STATUS_TX_EMPTY      0x04
26#define I8251_STATUS_RX_READY      0x02
27#define I8251_STATUS_TX_READY      0x01
28
29//**************************************************************************
30//  INTERFACE CONFIGURATION MACROS
31//**************************************************************************
32
33#define MCFG_I8251_ADD(_tag, _intrf) \
34   MCFG_DEVICE_ADD(_tag, I8251, 0) \
35   MCFG_DEVICE_CONFIG(_intrf)
36
37#define MCFG_I8251_REMOVE(_tag) \
38   MCFG_DEVICE_REMOVE(_tag)
39
40
41/***************************************************************************
42    TYPE DEFINITIONS
43***************************************************************************/
44// ======================> i8251_interface
45
46struct i8251_interface
47{
48   devcb_read_line      m_in_rxd_cb;
49   devcb_write_line   m_out_txd_cb;
50   devcb_read_line      m_in_dsr_cb;
51   devcb_write_line   m_out_dtr_cb;
52   devcb_write_line   m_out_rts_cb;
53   devcb_write_line   m_out_rxrdy_cb;
54   devcb_write_line   m_out_txrdy_cb;
55   devcb_write_line   m_out_txempty_cb;
56   devcb_write_line   m_out_syndet_cb;
57};
58
59// ======================> i8251_device
60
61class i8251_device :  public device_t,
62                 public i8251_interface
63{
64public:
65    // construction/destruction
66    i8251_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
67
68   /* read data register */
69   DECLARE_READ8_MEMBER(data_r);
70
71   /* read status register */
72   DECLARE_READ8_MEMBER(status_r);
73
74   /* write data register */
75   DECLARE_WRITE8_MEMBER(data_w);
76
77   /* write control word */
78   DECLARE_WRITE8_MEMBER(control_w);
79
80   /* The 8251 has seperate transmit and receive clocks */
81   /* use these two functions to update the i8251 for each clock */
82   /* on NC100 system, the clocks are the same */
83   void transmit_clock();
84   void receive_clock();
85
86   /* connecting to serial output */
87   void connect_to_serial_device(device_t *image);
88   void connect(serial_connection *other_connection);
89
90   void receive_character(UINT8 ch);
91   
92   serial_connection *get_connection() { return &m_connection; }
93protected:
94    // device-level overrides
95    virtual void device_start();
96   virtual void device_config_complete();
97   virtual void device_reset();
98
99   void update_rx_ready();
100   void update_tx_ready();
101   void update_tx_empty();
102private:
103   devcb_resolved_read_line   m_in_rxd_func;
104   devcb_resolved_write_line   m_out_txd_func;
105   devcb_resolved_read_line   m_in_dsr_func;
106   devcb_resolved_write_line   m_out_dtr_func;
107   devcb_resolved_write_line   m_out_rts_func;
108   devcb_resolved_write_line   m_out_rxrdy_func;
109   devcb_resolved_write_line   m_out_txrdy_func;
110   devcb_resolved_write_line   m_out_txempty_func;
111   devcb_resolved_write_line   m_out_syndet_func;
112
113   /* flags controlling how i8251_control_w operates */
114   UINT8 m_flags;
115   /* offset into sync_bytes used during sync byte transfer */
116   UINT8 m_sync_byte_offset;
117   /* number of sync bytes written so far */
118   UINT8 m_sync_byte_count;
119   /* the sync bytes written */
120   UINT8 m_sync_bytes[2];
121   /* status of i8251 */
122   UINT8 m_status;
123   UINT8 m_command;
124   /* mode byte - bit definitions depend on mode - e.g. synchronous, asynchronous */
125   UINT8 m_mode_byte;
126
127   /* data being received */
128   UINT8 m_data;
129
130   /* receive reg */
131   serial_receive_register m_receive_reg;
132   /* transmit reg */
133   serial_transmit_register m_transmit_reg;
134
135   data_form m_form;
136
137   /* the serial connection that data is transfered over */
138   /* this is usually connected to the serial device */
139   serial_connection m_connection;   
140};
141
142
143
144// device type definition
145extern const device_type I8251;
146
147extern const i8251_interface default_i8251_interface;
148
149#endif /* __I8251_H__ */
src/mess/machine/irisha.c
r12756r12757
1212#include "machine/i8255.h"
1313#include "machine/pit8253.h"
1414#include "machine/pic8259.h"
15#include "machine/msm8251.h"
15#include "machine/i8251.h"
1616#include "includes/irisha.h"
1717
1818
src/mess/machine/nc.c
r12756r12757
77#include "emu.h"
88#include "includes/nc.h"
99#include "machine/serial.h"
10#include "machine/msm8251.h"
10#include "machine/i8251.h"
1111#include "image.h"
1212
1313/*************************************************************************************************/
src/mess/machine/mbc55x.c
r12756r12757
296296   scan_keyboard(machine);
297297}
298298
299/* msm8251 serial */
299/* i8251 serial */
300300
301const i8251_interface mbc55x_msm8251a_interface =
301const i8251_interface mbc55x_i8251a_interface =
302302{
303303   DEVCB_NULL,
304304   DEVCB_NULL,
src/mess/machine/rmnimbus.c
r12756r12757
6060#include "machine/er59256.h"
6161#include "machine/pic8259.h"
6262#include "machine/pit8253.h"
63#include "machine/msm8251.h"
63#include "machine/i8251.h"
6464#include "machine/ctronics.h"
6565#include "machine/6522via.h"
6666#include "machine/scsi.h"
src/mess/includes/compis.h
r12756r12757
1717#include "cpu/mcs48/mcs48.h"
1818#include "video/upd7220.h"
1919#include "machine/ctronics.h"
20#include "machine/msm8251.h"
20#include "machine/i8251.h"
2121#include "machine/pit8253.h"
2222#include "machine/i8255.h"
2323#include "machine/pic8259.h"
src/mess/includes/pc8401a.h
r12756r12757
99#include "cpu/z80/z80.h"
1010#include "imagedev/cartslot.h"
1111#include "machine/i8255.h"
12#include "machine/msm8251.h"
12#include "machine/i8251.h"
1313#include "machine/ram.h"
1414#include "machine/upd1990a.h"
1515#include "video/mc6845.h"
r12756r12757
2424#define AY8910_TAG      "ay8910"
2525#define SED1330_TAG      "sed1330"
2626#define MC6845_TAG      "mc6845"
27#define I8251_TAG      "msm8251"
27#define I8251_TAG      "i8251"
2828
2929#define PC8401A_CRT_VIDEORAM_SIZE   0x2000
3030
src/mess/includes/pc8001.h
r12756r12757
1111#include "machine/ctronics.h"
1212#include "machine/8257dma.h"
1313#include "machine/i8255.h"
14#include "machine/msm8251.h"
14#include "machine/i8251.h"
1515#include "machine/ram.h"
1616#include "machine/upd1990a.h"
1717#include "sound/speaker.h"
src/mess/includes/px8.h
r12756r12757
1111#include "imagedev/cartslot.h"
1212#include "imagedev/cassette.h"
1313#include "machine/ram.h"
14#include "machine/msm8251.h"
14#include "machine/i8251.h"
1515#include "machine/pf10.h"
1616#include "sound/wave.h"
1717
src/mess/includes/bw2.h
r12756r12757
99#include "formats/basicdsk.h"
1010#include "machine/i8255.h"
1111#include "machine/ctronics.h"
12#include "machine/msm8251.h"
12#include "machine/i8251.h"
1313#include "machine/pit8253.h"
1414#include "machine/ram.h"
1515#include "machine/wd17xx.h"
src/mess/includes/mbc55x.h
r12756r12757
1414#include "machine/pit8253.h"
1515#include "machine/pic8259.h"
1616#include "machine/wd17xx.h"
17#include "machine/msm8251.h"
17#include "machine/i8251.h"
1818#include "sound/speaker.h"
1919#include "video/mc6845.h"
2020#include "imagedev/flopdrv.h"
r12756r12757
7171#define PIT_C2_CLOCK   1789770
7272
7373#define MONO_TAG                "mono"
74#define MSM8251A_KB_TAG      "msm8251a_kb"
74#define I8251A_KB_TAG         "i8251a_kb"
7575#define FDC_TAG                 "wd1793"
7676
7777
r12756r12757
9191      : driver_device(mconfig, type, tag),
9292   m_maincpu(*this, MAINCPU_TAG),
9393   m_crtc(*this, VID_MC6845_NAME),
94   m_kb_uart(*this, MSM8251A_KB_TAG),
94   m_kb_uart(*this, I8251A_KB_TAG),
9595   m_pit(*this, PIT8253_TAG),
9696   m_ppi(*this, PPI8255_TAG),
9797   m_pic(*this, PIC8259_TAG),
r12756r12757
161161extern const struct pit8253_config mbc55x_pit8253_config;
162162extern const struct pic8259_interface mbc55x_pic8259_config;
163163extern const i8255_interface mbc55x_ppi8255_interface;
164extern const i8251_interface mbc55x_msm8251a_interface;
165extern const i8251_interface mbc55x_msm8251b_interface;
164extern const i8251_interface mbc55x_i8251a_interface;
165extern const i8251_interface mbc55x_i8251b_interface;
166166
167167DRIVER_INIT(mbc55x);
168168MACHINE_RESET(mbc55x);
src/mess/includes/v1050.h
r12756r12757
1616#include "machine/i8214.h"
1717#include "machine/i8255.h"
1818#include "machine/msm58321.h"
19#include "machine/msm8251.h"
19#include "machine/i8251.h"
2020#include "machine/wd17xx.h"
2121#include "video/mc6845.h"
2222#include "sound/discrete.h"
src/mess/includes/cgc7900.h
r12756r12757
1010#include "cpu/mcs48/mcs48.h"
1111#include "formats/basicdsk.h"
1212#include "machine/ram.h"
13#include "machine/msm8251.h"
13#include "machine/i8251.h"
1414#include "sound/ay8910.h"
1515
1616#define M68000_TAG      "uh8"
src/mess/includes/kyocera.h
r12756r12757
1111#include "imagedev/cassette.h"
1212#include "machine/ctronics.h"
1313#include "machine/i8155.h"
14#include "machine/msm8251.h"
14#include "machine/i8251.h"
1515#include "machine/ram.h"
1616#include "machine/rp5c01.h"
1717#include "machine/upd1990a.h"
src/mess/includes/poly88.h
r12756r12757
88#define POLY88_H_
99
1010#include "machine/serial.h"
11#include "machine/msm8251.h"
11#include "machine/i8251.h"
1212#include "imagedev/snapquik.h"
1313
1414class poly88_state : public driver_device
src/mess/includes/pk8020.h
r12756r12757
1010#include "machine/i8255.h"
1111#include "machine/pit8253.h"
1212#include "machine/pic8259.h"
13#include "machine/msm8251.h"
13#include "machine/i8251.h"
1414#include "imagedev/cassette.h"
1515#include "sound/speaker.h"
1616#include "sound/wave.h"
src/mess/mess.mak
r12756r12757
527527   $(MESS_MACHINE)/hd63450.o   \
528528   $(MESS_MACHINE)/i82371ab.o   \
529529   $(MESS_MACHINE)/i82439tx.o   \
530   $(MESS_MACHINE)/i8251.o      \
530531   $(MESS_MACHINE)/i8271.o      \
531532   $(MESS_MACHINE)/ieee488.o   \
532533   $(MESS_MACHINE)/ieeestub.o   \
r12756r12757
539540   $(MESS_MACHINE)/mm58274c.o   \
540541   $(MESS_MACHINE)/mpc105.o   \
541542   $(MESS_MACHINE)/mos6530.o   \
542   $(MESS_MACHINE)/msm8251.o   \
543543   $(MESS_MACHINE)/s100.o      \
544544   $(MESS_MACHINE)/serial.o   \
545545   $(MESS_MACHINE)/upd765.o   \
src/mess/drivers/pc8401a.c
r12756r12757
578578   DEVCB_NULL
579579};
580580
581/* MSM8251 Interface */
581/* I8251 Interface */
582582
583583static const i8251_interface uart_intf =
584584{
src/mess/drivers/pc6001.c
r12756r12757
124124#include "emu.h"
125125#include "cpu/z80/z80.h"
126126#include "machine/i8255.h"
127#include "machine/msm8251.h"
127#include "machine/i8251.h"
128128#include "video/m6847.h"
129129#include "sound/ay8910.h"
130130#include "sound/wave.h"
src/mess/drivers/xor100.c
r12756r12757
4141#include "machine/com8116.h"
4242#include "machine/ctronics.h"
4343#include "machine/i8255.h"
44#include "machine/msm8251.h"
44#include "machine/i8251.h"
4545#include "machine/terminal.h"
4646#include "machine/wd17xx.h"
4747#include "machine/z80ctc.h"
src/mess/drivers/b2m.c
r12756r12757
1313#include "machine/i8255.h"
1414#include "machine/pit8253.h"
1515#include "machine/pic8259.h"
16#include "machine/msm8251.h"
16#include "machine/i8251.h"
1717#include "machine/wd17xx.h"
1818#include "imagedev/flopdrv.h"
1919#include "formats/basicdsk.h"
src/mess/drivers/pmd85.c
r12756r12757
176176#include "includes/pmd85.h"
177177#include "machine/i8255.h"
178178#include "machine/pit8253.h"
179#include "machine/msm8251.h"
179#include "machine/i8251.h"
180180#include "formats/pmd_pmd.h"
181181#include "machine/ram.h"
182182
src/mess/drivers/sg1000.c
r12756r12757
7474#include "formats/basicdsk.h"
7575#include "machine/ctronics.h"
7676#include "machine/i8255.h"
77#include "machine/msm8251.h"
77#include "machine/i8251.h"
7878#include "machine/upd765.h"
7979#include "video/tms9928a.h"
8080#include "sound/sn76496.h"
src/mess/drivers/irisha.c
r12756r12757
1212#include "machine/i8255.h"
1313#include "machine/pit8253.h"
1414#include "machine/pic8259.h"
15#include "machine/msm8251.h"
15#include "machine/i8251.h"
1616#include "includes/irisha.h"
1717
1818/* Address maps */
src/mess/drivers/einstein.c
r12756r12757
6363#include "cpu/z80/z80daisy.h"
6464#include "machine/wd17xx.h"
6565#include "machine/ctronics.h"
66#include "machine/msm8251.h"
66#include "machine/i8251.h"
6767#include "imagedev/flopdrv.h"
6868#include "sound/ay8910.h"
6969#include "video/mc6845.h"
r12756r12757
516516   /* block 1, tms9928a vdp */
517517   AM_RANGE(0x08, 0x08) AM_MIRROR(0xff06) AM_DEVREADWRITE_MODERN("tms9929a", tms9929a_device, vram_read, vram_write)
518518   AM_RANGE(0x09, 0x09) AM_MIRROR(0xff06) AM_DEVREADWRITE_MODERN("tms9929a", tms9929a_device, register_read, register_write)
519   /* block 2, msm8251 uart */
519   /* block 2, i8251 uart */
520520   AM_RANGE(0x10, 0x10) AM_MIRROR(0xff06) AM_DEVREADWRITE_MODERN(IC_I060, i8251_device, data_r, data_w)
521521   AM_RANGE(0x11, 0x11) AM_MIRROR(0xff06) AM_DEVREADWRITE_MODERN(IC_I060, i8251_device, status_r, control_w)
522522   /* block 3, wd1770 floppy controller */
src/mess/drivers/votrpss.c
r12756r12757
6767//#include "sound/votrax.h"
6868//#include "machine/i8255.h"
6969//#include "machine/pit8253.h"
70//#include "machine/msm8251.h"
70//#include "machine/i8251.h"
7171
7272/* For testing */
7373#include "machine/terminal.h"
r12756r12757
131131   AM_RANGE(0x41, 0x41) AM_READ(votrpss_41_r)
132132   //AM_RANGE(0x00, 0xff) AM_NOP /* temporary */
133133   //AM_RANGE(0x00, 0x03) AM_READWRITE(8255ppi_r, 8255ppi_w) AM_MIRROR (0x3c)
134   //AM_RANGE(0x40, 0x41) AM_READWRITE(msm8251_r, msm8251_w) AM_MIRROR (0x3e)
134   //AM_RANGE(0x40, 0x41) AM_READWRITE(i8251_r, i8251_w) AM_MIRROR (0x3e)
135135   //AM_RANGE(0x80, 0x83) AM_READWRITE(pit8253_r, pit8253_w) AM_MIRROR (0x3c)
136136   //AM_RANGE(0xc0, 0xc3) AM_READWRITE(ay8910_r, ay8910_W) AM_MIRROR (0x3c)
137137ADDRESS_MAP_END
src/mess/drivers/fk1.c
r12756r12757
1111#include "cpu/z80/z80.h"
1212#include "machine/i8255.h"
1313#include "machine/pit8253.h"
14#include "machine/msm8251.h"
14#include "machine/i8251.h"
1515#include "machine/ram.h"
1616
1717#define MACHINE_RESET_MEMBER(name) void name::machine_reset()
src/mess/drivers/kyocera.c
r12756r12757
10931093   DEVCB_DRIVER_LINE_MEMBER(tandy200_state, i8155_to_w)   /* timer output */
10941094};
10951095
1096/* MSM8251 Interface */
1096/* I8251 Interface */
10971097
10981098static const i8251_interface tandy200_uart_intf =
10991099{
src/mess/drivers/sage2.c
r12756r12757
1313
1414#include "emu.h"
1515#include "cpu/m68000/m68000.h"
16#include "machine/msm8251.h"
16#include "machine/i8251.h"
1717#include "machine/terminal.h"
1818
1919
src/mess/drivers/tandy2k.c
r12756r12757
3333#include "machine/ram.h"
3434#include "machine/ctronics.h"
3535#include "machine/i8255.h"
36#include "machine/msm8251.h"
36#include "machine/i8251.h"
3737#include "machine/pit8253.h"
3838#include "machine/pic8259.h"
3939#include "machine/upd765.h"
src/mess/drivers/sm1800.c
r12756r12757
1717#include "emu.h"
1818#include "cpu/i8085/i8085.h"
1919#include "machine/i8255.h"
20#include "machine/msm8251.h"
20#include "machine/i8251.h"
2121#include "video/i8275.h"
2222
2323#define MACHINE_RESET_MEMBER(name) void name::machine_reset()
src/mess/drivers/nc.c
r12756r12757
9999#include "includes/nc.h"
100100#include "machine/serial.h"   /* for serial data transfers */
101101#include "machine/ctronics.h"
102#include "machine/msm8251.h"   /* for NC100 uart */
102#include "machine/i8251.h"   /* for NC100 uart */
103103#include "machine/mc146818.h"   /* for NC200 real time clock */
104104#include "machine/rp5c01.h"   /* for NC100 real time clock */
105105#include "machine/upd765.h"      /* for NC200 disk drive interface */
r12756r12757
117117#define LOG_DEBUG(x) do { if (NC200_DEBUG) logerror x; } while (0)
118118
119119
120/* the serial clock is generated by the nc hardware and connected to the msm8251
120/* the serial clock is generated by the nc hardware and connected to the i8251
121121receive clock and transmit clock inputs */
122122
123123static void nc_printer_update(running_machine &machine, UINT8 data);
src/mess/drivers/mbc55x.c
r12756r12757
264264   MCFG_SOUND_ROUTE(ALL_OUTPUTS,MONO_TAG, 0.75)
265265
266266   /* Devices */
267   MCFG_I8251_ADD(MSM8251A_KB_TAG,mbc55x_msm8251a_interface)
267   MCFG_I8251_ADD(I8251A_KB_TAG,mbc55x_i8251a_interface)
268268   MCFG_PIT8253_ADD( PIT8253_TAG, mbc55x_pit8253_config )
269269   MCFG_PIC8259_ADD( PIC8259_TAG, mbc55x_pic8259_config )
270270   MCFG_I8255_ADD( PPI8255_TAG, mbc55x_ppi8255_interface )
src/mess/drivers/tsispch.c
r12756r12757
104104#include "includes/tsispch.h"
105105#include "cpu/upd7725/upd7725.h"
106106#include "cpu/i86/i86.h"
107#include "machine/msm8251.h"
107#include "machine/i8251.h"
108108#include "machine/pic8259.h"
109109#include "machine/terminal.h"
110110
r12756r12757
143143   pic8259_ir3_w(device->machine().device("pic8259"), state);
144144}
145145
146const i8251_interface msm8251_config =
146const i8251_interface i8251_config =
147147{
148   DEVCB_NULL, // in rxd, serial (todo: proper hookup, currently using hack w/msm8251_recieve_character())
148   DEVCB_NULL, // in rxd, serial (todo: proper hookup, currently using hack w/i8251_recieve_character())
149149   DEVCB_NULL, // out txd, serial
150150   DEVCB_NULL, // in dsr
151151   DEVCB_NULL, // out dtr
r12756r12757
424424    MCFG_PIC8259_ADD("pic8259", pic8259_config)
425425
426426    /* uarts */
427    MCFG_I8251_ADD("i8251a_u15", msm8251_config)
427    MCFG_I8251_ADD("i8251a_u15", i8251_config)
428428
429429    /* sound hardware */
430430    //MCFG_SPEAKER_STANDARD_MONO("mono")
src/mess/drivers/elwro800.c
r12756r12757
2222#include "sound/speaker.h"
2323#include "sound/wave.h"
2424#include "machine/ctronics.h"
25#include "machine/msm8251.h"
25#include "machine/i8251.h"
2626
2727/* Devices */
2828#include "imagedev/flopdrv.h"
r12756r12757
296296   else if (!BIT(cs,4))
297297   {
298298      // CS51
299      i8251_device *usart = space->machine().device<i8251_device>("msm8251");
299      i8251_device *usart = space->machine().device<i8251_device>("i8251");
300300      if (offset & 1)
301301      {
302302         return usart->status_r(*space, 0);
r12756r12757
350350   else if (!BIT(cs,4))
351351   {
352352      // CS51
353      i8251_device *usart = space->machine().device<i8251_device>("msm8251");
353      i8251_device *usart = space->machine().device<i8251_device>("i8251");
354354      if (offset & 1)
355355      {
356356         usart->control_w(*space, 0, data);
r12756r12757
602602   /* printer */
603603   MCFG_CENTRONICS_ADD("centronics", elwro800jr_centronics_interface)
604604
605   MCFG_I8251_ADD("msm8251", default_i8251_interface)
605   MCFG_I8251_ADD("i8251", default_i8251_interface)
606606
607607   /* sound hardware */
608608   MCFG_SPEAKER_STANDARD_MONO("mono")
src/mess/drivers/vixen.c
r12756r12757
6161#include "machine/ram.h"
6262#include "machine/i8155.h"
6363#include "machine/ieee488.h"
64#include "machine/msm8251.h"
64#include "machine/i8251.h"
6565#include "machine/wd17xx.h"
6666#include "sound/discrete.h"
6767#include "includes/vixen.h"

Previous 15994 Revisions Next


© 1998-2018 The MESS Team