Previous 199869 Revisions Next

r24031 Monday 1st July, 2013 at 13:56:21 UTC by Carl
diserial: simplify (nw)
ins8250: use clock-div rate setting for more precision (nw)
[src/emu]diserial.c diserial.h
[src/emu/machine]ins8250.c ins8250.h

trunk/src/emu/machine/ins8250.c
r24030r24031
190190   update_interrupt();
191191}
192192
193void ins8250_uart_device::update_clock()
194{
195   int baud;
196   if(m_regs.dl == 0)
197   {
198      set_tra_rate(0);
199      set_rcv_rate(0);
200      return;
201   }
202   baud = clock()/(m_regs.dl*16);
203   set_tra_rate(baud);
204   set_rcv_rate(baud);
205}
206
207193WRITE8_MEMBER( ins8250_uart_device::ins8250_w )
208194{
209195   int tmp;
r24030r24031
214200         if (m_regs.lcr & 0x80)
215201         {
216202            m_regs.dl = (m_regs.dl & 0xff00) | data;
217            update_clock();
203            set_rate(clock(), m_regs.dl*16);
218204         }
219205         else
220206         {
r24030r24031
240226         if (m_regs.lcr & 0x80)
241227         {
242228            m_regs.dl = (m_regs.dl & 0xff) | (data << 8);
243            update_clock();
229            set_rate(clock(), m_regs.dl*16);
244230         }
245231         else
246232         {
trunk/src/emu/machine/ins8250.h
r24030r24031
8484   devcb_resolved_write_line   m_out_out2_func;
8585
8686   void update_interrupt();
87   void update_clock();
8887   void update_msr(int bit, UINT8 state);
8988};
9089
trunk/src/emu/diserial.c
r24030r24031
6565   m_tra_clock = device().machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(device_serial_interface::tra_timer), this));
6666}
6767
68void device_serial_interface::set_rcv_rate(int baud)
69{
70   m_rcv_rate = baud ? attotime::from_hz(baud) : attotime::never;
71   receive_register_reset();
72   m_rcv_clock->adjust(attotime::never);
73}
74
75void device_serial_interface::set_tra_rate(int baud)
76{
77   m_tra_rate = baud ? attotime::from_hz(baud) : attotime::never;
78   transmit_register_reset();
79   m_tra_clock->adjust(attotime::never);
80}
81
8268void device_serial_interface::set_rcv_rate(attotime rate)
8369{
8470   m_rcv_rate = rate;
r24030r24031
9379   m_tra_clock->adjust(attotime::never);
9480}
9581
96void device_serial_interface::set_rcv_rate(UINT32 clock, int div)
97{
98   m_rcv_rate = attotime::from_hz(clock) * div;
99   receive_register_reset();
100   m_rcv_clock->adjust(attotime::never);
101}
102
103void device_serial_interface::set_tra_rate(UINT32 clock, int div)
104{
105   m_tra_rate = attotime::from_hz(clock) * div;
106   transmit_register_reset();
107   m_tra_clock->adjust(attotime::never);
108}
109
11082void device_serial_interface::tra_clock()
11183{
11284   tra_callback();
trunk/src/emu/diserial.h
r24030r24031
9191   void receive_register_update_bit(int bit);
9292   void receive_register_extract();
9393
94   void set_rcv_rate(attotime baud);
95   void set_tra_rate(attotime baud);
96   void set_rcv_rate(UINT32 clock, int div);
97   void set_tra_rate(UINT32 clock, int div);
98   void set_rcv_rate(int baud);
99   void set_tra_rate(int baud);
94   void set_rcv_rate(attotime rate);
95   void set_tra_rate(attotime rate);
96   void set_rcv_rate(UINT32 clock, int div) { set_rcv_rate((clock && div) ? (attotime::from_hz(clock) * div) : attotime::never); }
97   void set_tra_rate(UINT32 clock, int div) { set_tra_rate((clock && div) ? (attotime::from_hz(clock) * div) : attotime::never); }
98   void set_rcv_rate(int baud) { set_rcv_rate(baud ? attotime::from_hz(baud) : attotime::never); }
99   void set_tra_rate(int baud) { set_tra_rate(baud ? attotime::from_hz(baud) : attotime::never); }
100   void set_rate(attotime rate) { set_rcv_rate(rate); set_tra_rate(rate); }
101   void set_rate(UINT32 clock, int div) { set_rcv_rate(clock, div); set_tra_rate(clock, div); }
102   void set_rate(int baud) { set_rcv_rate(baud); set_tra_rate(baud); }
103
100104   void tra_clock();
101105   void rcv_clock();
102106

Previous 199869 Revisions Next


© 1997-2024 The MAME Team