Previous 199869 Revisions Next

r26688 Sunday 22nd December, 2013 at 19:01:57 UTC by smf
replaced read rx callback in MC68901 with a write handler, which allows multiple chips to be connected together without using glue methods. Removed a load of unused code from MC68901, probably left over when it was converted to use diserial. [smf]
[src/emu/machine]mc68901.c mc68901.h
[src/mame/drivers]micro3d.c
[src/mess/drivers]atarist.c x68k.c

trunk/src/emu/machine/mc68901.c
r26687r26688
176176const int mc68901_device::PRESCALER[] = { 0, 4, 10, 16, 50, 64, 100, 200 };
177177
178178
179#define TXD(_data) m_out_so_func(_data);
180
181
182179//**************************************************************************
183180//  INLINE HELPERS
184181//**************************************************************************
r26687r26688
222219   }
223220}
224221
225inline void mc68901_device::tx_buffer_empty()
226{
227   if (m_ier & IR_XMIT_BUFFER_EMPTY)
228   {
229      take_interrupt(IR_XMIT_BUFFER_EMPTY);
230   }
231}
232
233inline void mc68901_device::tx_error()
234{
235   if (m_ier & IR_XMIT_ERROR)
236   {
237      take_interrupt(IR_XMIT_ERROR);
238   }
239   else
240   {
241      tx_buffer_empty();
242   }
243}
244
245inline int mc68901_device::get_parity_bit(UINT8 b)
246{
247   b ^= b >> 4;
248   b ^= b >> 2;
249   b ^= b >> 1;
250   return b & 1;
251}
252
253inline void mc68901_device::serial_receive()
254{
255   int rxd;
256
257   if (!(m_rsr & RSR_RCV_ENABLE)) return;
258
259   rxd = m_in_si_func();
260
261   switch (m_rx_state)
262   {
263   case SERIAL_START:
264      if (!rxd)
265      {
266         m_rsr |= RSR_CHAR_IN_PROGRESS;
267         m_rx_bits = 0;
268         m_rx_buffer = 0;
269         m_rx_state = SERIAL_DATA;
270         m_next_rsr = RSR_BREAK;
271      }
272      break;
273
274   case SERIAL_DATA:
275      if ((m_next_rsr & RSR_BREAK) && (rxd == 1) && m_rsr_read)
276      {
277         m_next_rsr &= ~RSR_BREAK;
278      }
279
280      m_rx_buffer >>= 1;
281      m_rx_buffer |= (rxd << 7);
282      m_rx_bits++;
283
284      if (m_rx_bits == m_rxtx_word)
285      {
286         if (m_rxtx_word < 8)
287         {
288            m_rx_buffer >>= (8 - m_rxtx_word);
289         }
290
291         m_rsr &= ~RSR_CHAR_IN_PROGRESS;
292
293         if (m_ucr & UCR_PARITY_ENABLED)
294         {
295            m_rx_state = SERIAL_PARITY;
296         }
297         else
298         {
299            m_rx_state = SERIAL_STOP;
300         }
301      }
302      break;
303
304   case SERIAL_PARITY:
305      m_rx_parity = rxd;
306
307      if (m_rx_parity != (get_parity_bit(m_rx_buffer) ^ ((m_ucr & UCR_PARITY_EVEN) >> 1)))
308      {
309         m_next_rsr |= RSR_PARITY_ERROR;
310      }
311
312      m_rx_state = SERIAL_STOP;
313      break;
314
315   case SERIAL_STOP:
316      if (rxd == 1)
317      {
318         if (!((m_rsr & RSR_SYNC_STRIP_ENABLE) && (m_rx_buffer == m_scr)))
319         {
320            if (!(m_rsr & RSR_OVERRUN_ERROR))
321            {
322               if (m_rsr & RSR_BUFFER_FULL)
323               {
324                  // incoming word received but last word in receive buffer has not been read
325                  m_next_rsr |= RSR_OVERRUN_ERROR;
326               }
327               else
328               {
329                  // incoming word received and receive buffer is empty
330                  m_rsr |= RSR_BUFFER_FULL;
331                  m_udr = m_rx_buffer;
332                  rx_buffer_full();
333               }
334            }
335         }
336      }
337      else
338      {
339         if (m_rx_buffer)
340         {
341            // non-zero data word not followed by a stop bit
342            m_next_rsr |= RSR_FRAME_ERROR;
343         }
344      }
345
346      m_rx_state = SERIAL_START;
347      break;
348   }
349}
350
351
352inline void mc68901_device::tx_disabled()
353{
354   switch (m_tsr & TSR_OUTPUT_MASK)
355   {
356   case TSR_OUTPUT_HI_Z:
357      /* indeterminate state */
358   case TSR_OUTPUT_LOW:
359      TXD(0);
360      break;
361
362   case TSR_OUTPUT_HIGH:
363   case TSR_OUTPUT_LOOP:
364      TXD(1);
365      break;
366   }
367}
368
369
370inline void mc68901_device::tx_starting()
371{
372   if (m_tsr & TSR_XMIT_ENABLE)
373   {
374      /* enable transmitter */
375      TXD(1);
376      m_xmit_state = XMIT_ON;
377   }
378   else
379   {
380      /* disable transmitter */
381      m_tsr |= TSR_END_OF_XMIT;
382      m_xmit_state = XMIT_OFF;
383   }
384}
385
386
387inline void mc68901_device::tx_break()
388{
389   if (m_tsr & TSR_XMIT_ENABLE)
390   {
391      if (m_tsr & TSR_BREAK)
392      {
393         /* transmit break */
394         TXD(1);
395      }
396      else
397      {
398         /* enable transmitter */
399         m_xmit_state = XMIT_ON;
400      }
401   }
402   else
403   {
404      /* disable transmitter */
405      m_tsr |= TSR_END_OF_XMIT;
406      m_xmit_state = XMIT_OFF;
407   }
408}
409
410
411inline void mc68901_device::tx_enabled()
412{
413   switch (m_tx_state)
414   {
415   case SERIAL_START:
416      if (m_tsr & TSR_UNDERRUN_ERROR)
417      {
418         /* buffer underrun condition */
419         if (m_tsr & TSR_XMIT_ENABLE)
420         {
421            /* transmit break */
422            TXD(1);
423         }
424         else
425         {
426            /* transmitter disabled */
427            tx_disabled();
428         }
429      }
430      else
431      {
432         if (m_tsr & TSR_BUFFER_EMPTY)
433         {
434            /* transmit buffer is empty, signal underrun error */
435            m_tsr |= TSR_UNDERRUN_ERROR;
436
437            if (m_tsr & TSR_XMIT_ENABLE)
438            {
439               /* transmit break */
440               TXD(1);
441            }
442            else
443            {
444               /* transmitter disabled */
445               tx_disabled();
446            }
447         }
448         else
449         {
450            /* transmit start bit */
451            TXD(0);
452
453            /* load transmit buffer */
454            m_tx_buffer = m_udr;
455            m_tx_bits = 0;
456
457            /* signal transmit buffer empty */
458            m_tsr |= TSR_BUFFER_EMPTY;
459            tx_buffer_empty();
460
461            /* calculate parity */
462            m_tx_parity = get_parity_bit(m_tx_buffer);
463
464            /* next bit is data */
465            m_tx_state = SERIAL_DATA;
466         }
467      }
468      break;
469
470   case SERIAL_DATA:
471      /* transmit data bit */
472      TXD(m_tx_buffer & 0x01);
473
474      /* shift transmit buffer */
475      m_tx_buffer >>= 1;
476      m_tx_bits++;
477
478      if (m_tx_bits == m_rxtx_word)
479      {
480         /* all data bits transferred */
481         if (m_ucr & UCR_PARITY_ENABLED)
482         {
483            /* next bit is parity */
484            m_tx_state = SERIAL_PARITY;
485         }
486         else
487         {
488            /* next bit is stop */
489            m_tx_state = SERIAL_STOP;
490         }
491      }
492      break;
493
494   case SERIAL_PARITY:
495      if (m_rxtx_word < 8)
496      {
497         /* transmit user-defined parity bit from buffer */
498         TXD(m_tx_buffer & 0x01);
499      }
500      else
501      {
502         /* transmit calculated parity bit */
503         TXD(m_tx_parity ^ ((m_ucr & UCR_PARITY_EVEN) >> 1));
504      }
505
506      /* next bit is stop */
507      m_tx_state = SERIAL_STOP;
508      break;
509
510   case SERIAL_STOP:
511      /* transmit stop bit */
512      TXD(1);
513
514      if (m_tsr & TSR_XMIT_ENABLE)
515      {
516         /* next bit is start */
517         m_tx_state = SERIAL_START;
518      }
519      else
520      {
521         if (m_tsr & TSR_AUTO_TURNAROUND)
522         {
523            /* enable transmitter */
524            m_tsr |= TSR_XMIT_ENABLE;
525
526            /* next bit is start */
527            m_tx_state = SERIAL_START;
528         }
529         else
530         {
531            /* disable transmitter */
532            m_xmit_state = XMIT_OFF;
533            m_tsr |= TSR_END_OF_XMIT;
534
535            /* signal transmit error */
536            tx_error();
537         }
538      }
539      break;
540   }
541}
542
543inline void mc68901_device::serial_transmit()
544{
545   switch (m_xmit_state)
546   {
547   case XMIT_OFF:      tx_disabled();  break;
548   case XMIT_STARTING: tx_starting();  break;
549   case XMIT_BREAK:    tx_break();     break;
550   case XMIT_ON:       tx_enabled();   break;
551   }
552}
553
554
555222inline void mc68901_device::timer_count(int index)
556223{
557224   if (m_tmc[index] == 0x01)
r26687r26688
691358   /* resolve callbacks */
692359   m_in_gpio_func.resolve(m_in_gpio_cb, *this);
693360   m_out_gpio_func.resolve(m_out_gpio_cb, *this);
694   m_in_si_func.resolve(m_in_si_cb, *this);
695361   m_out_so_func.resolve(m_out_so_cb, *this);
696362   m_out_tao_func.resolve(m_out_tao_cb, *this);
697363   m_out_tbo_func.resolve(m_out_tbo_cb, *this);
r26687r26688
835501
836502void mc68901_device::rcv_callback()
837503{
838   if (m_in_si_func.isnull())
839      receive_register_update_bit(get_in_data_bit());
840   else
841      receive_register_update_bit(m_in_si_func());
504   receive_register_update_bit(get_in_data_bit());
842505}
843506
844507
r26687r26688
14391102{
14401103   timer_input(TIMER_B, state);
14411104}
1105
1106WRITE_LINE_MEMBER(mc68901_device::write_rx)
1107{
1108   if (state)
1109   {
1110      input_callback(m_input_state | RX);
1111   }
1112   else
1113   {
1114      input_callback(m_input_state & ~RX);
1115   }
1116}
1117
1118WRITE_LINE_MEMBER(mc68901_device::write_dsr)
1119{
1120   if (state)
1121   {
1122      input_callback(m_input_state | DSR);
1123   }
1124   else
1125   {
1126      input_callback(m_input_state & ~DSR);
1127   }
1128}
trunk/src/emu/machine/mc68901.h
r26687r26688
8787   devcb_write_line        m_out_tco_cb;
8888   devcb_write_line        m_out_tdo_cb;
8989
90   devcb_read_line         m_in_si_cb;
9190   devcb_write_line        m_out_so_cb;
9291   devcb_write_line        m_out_rr_cb;
9392   devcb_write_line        m_out_tr_cb;
r26687r26688
122121   DECLARE_WRITE_LINE_MEMBER( tai_w );
123122   DECLARE_WRITE_LINE_MEMBER( tbi_w );
124123
124   DECLARE_WRITE_LINE_MEMBER( write_rx );
125   DECLARE_WRITE_LINE_MEMBER( write_dsr );
126
125127protected:
126128   // device-level overrides
127129   virtual void device_config_complete();
r26687r26688
140142   void take_interrupt(UINT16 mask);
141143   void rx_buffer_full();
142144   void rx_error();
143   void tx_buffer_empty();
144   void tx_error();
145   int get_parity_bit(UINT8 b);
146   void serial_receive();
147   void tx_disabled();
148   void tx_starting();
149   void tx_break();
150   void tx_enabled();
151   void serial_transmit();
152145   void timer_count(int index);
153146   void timer_input(int index, int value);
154147   void gpio_input(int bit, int state);
r26687r26688
247240
248241   devcb_resolved_read8        m_in_gpio_func;
249242   devcb_resolved_write8       m_out_gpio_func;
250   devcb_resolved_read_line    m_in_si_func;
251243   devcb_resolved_write_line   m_out_so_func;
252244   devcb_resolved_write_line   m_out_tao_func;
253245   devcb_resolved_write_line   m_out_tbo_func;
trunk/src/mess/drivers/x68k.c
r26687r26688
20662066   DEVCB_NULL,                                         /* TBO */
20672067   DEVCB_NULL,                                         /* TCO */
20682068   DEVCB_DRIVER_LINE_MEMBER(x68k_state, mfp_tdo_w),    /* TDO */
2069   DEVCB_NULL,                                         /* serial input */
20702069   DEVCB_NULL,                                         /* serial output */
20712070   DEVCB_NULL,
20722071   DEVCB_NULL
trunk/src/mess/drivers/atarist.c
r26687r26688
19461946   DEVCB_NULL,                                         /* TBO */
19471947   DEVCB_NULL,                                         /* TCO */
19481948   DEVCB_DRIVER_LINE_MEMBER(st_state, mfp_tdo_w),      /* TDO */
1949   DEVCB_DEVICE_LINE_MEMBER(RS232_TAG, serial_port_device, rx),
19501949   DEVCB_DEVICE_LINE_MEMBER(RS232_TAG, serial_port_device, tx)
19511950};
19521951
r26687r26688
20132012   DEVCB_NULL,                                         /* TBO */
20142013   DEVCB_NULL,                                         /* TCO */
20152014   DEVCB_DRIVER_LINE_MEMBER(st_state, mfp_tdo_w),      /* TDO */
2016   DEVCB_DEVICE_LINE_MEMBER(RS232_TAG, serial_port_device, rx),
20172015   DEVCB_DEVICE_LINE_MEMBER(RS232_TAG, serial_port_device, tx)
20182016};
20192017
r26687r26688
20792077   DEVCB_NULL,                                         /* TBO */
20802078   DEVCB_NULL,                                         /* TCO */
20812079   DEVCB_DRIVER_LINE_MEMBER(st_state, mfp_tdo_w),      /* TDO */
2082   DEVCB_DEVICE_LINE_MEMBER(RS232_TAG, serial_port_device, rx),
20832080   DEVCB_DEVICE_LINE_MEMBER(RS232_TAG, serial_port_device, tx)
20842081};
20852082
r26687r26688
23882385   MCFG_FLOPPY_DRIVE_ADD(WD1772_TAG ":1", atari_floppies, 0,      st_state::floppy_formats)
23892386
23902387   MCFG_CENTRONICS_PRINTER_ADD(CENTRONICS_TAG, centronics_intf)
2388
23912389   MCFG_RS232_PORT_ADD(RS232_TAG, default_rs232_devices, NULL)
2390   MCFG_SERIAL_OUT_RX_HANDLER(DEVWRITELINE(MC68901_TAG, mc68901_device, write_rx))
23922391
23932392   MCFG_SERIAL_PORT_ADD("mdin", midiin_slot, "midiin")
23942393   MCFG_SERIAL_OUT_RX_HANDLER(WRITELINE(st_state, midi_rx_w))
r26687r26688
24462445   MCFG_FLOPPY_DRIVE_ADD(WD1772_TAG ":0", atari_floppies, "35dd", st_state::floppy_formats)
24472446   MCFG_FLOPPY_DRIVE_ADD(WD1772_TAG ":1", atari_floppies, 0,      st_state::floppy_formats)
24482447   MCFG_CENTRONICS_PRINTER_ADD(CENTRONICS_TAG, centronics_intf)
2448
24492449   MCFG_RS232_PORT_ADD(RS232_TAG, default_rs232_devices, NULL)
2450   MCFG_SERIAL_OUT_RX_HANDLER(DEVWRITELINE(MC68901_TAG, mc68901_device, write_rx))
24502451
24512452   MCFG_SERIAL_PORT_ADD("mdin", midiin_slot, "midiin")
24522453   MCFG_SERIAL_OUT_RX_HANDLER(WRITELINE(st_state, midi_rx_w))
r26687r26688
25132514   MCFG_FLOPPY_DRIVE_ADD(WD1772_TAG ":0", atari_floppies, "35dd", st_state::floppy_formats)
25142515   MCFG_FLOPPY_DRIVE_ADD(WD1772_TAG ":1", atari_floppies, 0,      st_state::floppy_formats)
25152516   MCFG_CENTRONICS_PRINTER_ADD(CENTRONICS_TAG, centronics_intf)
2517
25162518   MCFG_RS232_PORT_ADD(RS232_TAG, default_rs232_devices, NULL)
2519   MCFG_SERIAL_OUT_RX_HANDLER(DEVWRITELINE(MC68901_TAG, mc68901_device, write_rx))
25172520
25182521   MCFG_SERIAL_PORT_ADD("mdin", midiin_slot, "midiin")
25192522   MCFG_SERIAL_OUT_RX_HANDLER(WRITELINE(st_state, midi_rx_w))
r26687r26688
25902593   MCFG_FLOPPY_DRIVE_ADD(WD1772_TAG ":0", atari_floppies, "35dd", 0, st_state::floppy_formats)
25912594   MCFG_FLOPPY_DRIVE_ADD(WD1772_TAG ":1", atari_floppies, 0,      0, st_state::floppy_formats)
25922595   MCFG_CENTRONICS_PRINTER_ADD(CENTRONICS_TAG, centronics_intf)
2593   MCFG_RS232_PORT_ADD(RS232_TAG, default_rs232_devices, NULL, NULL)
25942596
2597   MCFG_RS232_PORT_ADD(RS232_TAG, default_rs232_devices, NULL)
2598   MCFG_SERIAL_OUT_RX_HANDLER(DEVWRITELINE(MC68901_TAG, mc68901_device, write_rx))
2599
25952600   MCFG_SERIAL_PORT_ADD("mdin", midiin_slot, "midiin")
25962601   MCFG_SERIAL_OUT_RX_HANDLER(WRITELINE(st_state, midi_rx_w))
25972602
trunk/src/mame/drivers/micro3d.c
r26687r26688
319319   DEVCB_NULL,                                         /* TBO */
320320   DEVCB_NULL,                                         /* TCO */
321321   DEVCB_NULL,                                         /* TDO */
322   DEVCB_NULL,                                         /* serial input */
323   DEVCB_NULL                                          /* serial output */
322   DEVCB_NULL,                                         /* serial output */
323   DEVCB_NULL,
324   DEVCB_NULL
324325};
325326
326327

Previous 199869 Revisions Next


© 1997-2024 The MAME Team