Previous 199869 Revisions Next

r29630 Monday 14th April, 2014 at 08:21:40 UTC by Robbbert
(MESS) Serial Keyboard : If clock is specified, it becomes the initial baud rate. Updated documentation. This fixes a regression with MESS 'binbug' driver.
[src/emu/bus/rs232]keyboard.c keyboard.h

trunk/src/emu/bus/rs232/keyboard.c
r29629r29630
11/***************************************************************************
2Generic ASCII Keyboard
2Generic ASCII Serial Keyboard
33
44Use MCFG_SERIAL_KEYBOARD_ADD to attach this as a serial device to a terminal
55or computer.
66
7Use MCFG_ASCII_KEYBOARD_ADD to attach as a generic ascii input device in
8cases where either the driver isn't developed enough yet; or for testing;
9or for the case of a computer with an inbuilt (not serial) ascii keyboard.
107
118Example of usage in a driver.
129
1310In MACHINE_CONFIG
14    MCFG_ASCII_KEYBOARD_ADD(KEYBOARD_TAG, keyboard_intf)
11   MCFG_SERIAL_KEYBOARD_ADD(KEYBOARD_TAG, keyboard_intf, 0)
12or
13   MCFG_SERIAL_KEYBOARD_ADD(KEYBOARD_TAG, keyboard_intf, initial_baud_rate)
1514
15
1616In the code:
1717
1818WRITE8_MEMBER( xxx_state::kbd_put )
r29629r29630
2525    DEVCB_DRIVER_MEMBER(xxx_state, kbd_put)
2626};
2727
28If a baud_rate is specified, it will be the initial baud rate, with
298 bits, no parity, 1 stop bit. However you can override this with the
30config switches. (Note that the config switch will specify 9600 initially,
31even though it isn't).
32
33If a baud_rate is not specified, the rate will be solely determined
34by the config switches. (Default 9600 baud)
35
36
2837***************************************************************************/
2938
3039#include "keyboard.h"
r29629r29630
96105
97106void serial_keyboard_device::device_start()
98107{
99   int baud = clock();
100   if(!baud) baud = 9600;
108   m_baud = clock();
101109   m_out_tx_func.resolve(m_out_tx_cb, *this);
102110   m_timer = timer_alloc();
103   set_data_frame(1, 8, PARITY_NONE, STOP_BITS_1);
104   set_tra_rate(baud);
111
112   if (m_baud)
113   {
114      set_data_frame(1, 8, PARITY_NONE, STOP_BITS_1);
115      set_tra_rate(m_baud);
116   }
105117}
106118
107119INPUT_CHANGED_MEMBER(serial_keyboard_device::update_frame)
108120{
121   m_baud = 0;
109122   reset();
110123}
111124
r29629r29630
118131   else
119132      m_out_tx_func(m_rbit);
120133
121   UINT8 val = m_io_term_frame->read();
122   set_tra_rate(rates[val & 0x0f]);
134   if (m_baud == 0)
135   {
136      UINT8 val = m_io_term_frame->read();
137      set_tra_rate(rates[val & 0x0f]);
123138
124   switch(val & 0x30)
125   {
126   case 0x10:
127      set_data_frame(1, 7, PARITY_EVEN, STOP_BITS_1);
128      break;
129   case 0x00:
130   default:
131      set_data_frame(1, 8, PARITY_NONE, STOP_BITS_1);
132      break;
133   case 0x20:
134      set_data_frame(1, 8, PARITY_NONE, STOP_BITS_2);
135      break;
136   case 0x30:
137      set_data_frame(1, 8, PARITY_EVEN, STOP_BITS_1);
138      break;
139      switch(val & 0x30)
140      {
141      case 0x10:
142         set_data_frame(1, 7, PARITY_EVEN, STOP_BITS_1);
143         break;
144      case 0x00:
145      default:
146         set_data_frame(1, 8, PARITY_NONE, STOP_BITS_1);
147         break;
148      case 0x20:
149         set_data_frame(1, 8, PARITY_NONE, STOP_BITS_2);
150         break;
151      case 0x30:
152         set_data_frame(1, 8, PARITY_EVEN, STOP_BITS_1);
153         break;
154      }
139155   }
140156}
141157
trunk/src/emu/bus/rs232/keyboard.h
r29629r29630
5252   virtual void send_key(UINT8 code);
5353private:
5454   int m_rbit;
55   int m_baud;
5556   UINT8 m_curr_key;
5657   bool m_key_valid;
5758   devcb_resolved_write_line m_out_tx_func;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team