Previous 15994 Revisions Next

r2831 Saturday 7th June, 2008 at 06:33:26 UTC by Robbbert
[AY31015] Added support for similar UARTS.
[src/mess/machine]ay31015.c ay31015.h

src/mess/machine/ay31015.c
r2830r2831
22 
33   ay31015.c by Robbbert, May 2008
44 
5   Code for the AY3-1015 UART
5   Code for the AY-3-1014A, AY-3-1015(D), AY-5-1013(A) and AY-6-1013 UARTs
66 
77   This is cycle-accurate according to the specifications.
88 
r2830r2831
1313 
1414   - If you find bugs, please fix them yourself.
1515   - If you want to convert it to a DEVICE, please do so.
16   - If you want to add support for multiple instances, please do so.
1617 
17****************************************************************************/
18*****************************************************************************
1819 
19/* It is not clear in the documentation as to which settings will reset the device.
20Differences between the chip types:
21- All units have pull-up resistors on the inputs, except for the AY-3-1014A which is CMOS-compatible.
22- AY-3-1014A and AY-3-1015 - 1.5 stop bits mode available.
23- Max baud rate of 30k, except AY-5-1013 which has 20k.
24- AY-5-1013 has extended temperature ratings.
25- AY-5-1013 and AY-6-1013 require a -12 volt supply on pin 2. Pin is not used otherwise.
26- AY-5-1013 and AY-6-1013 do not reset the received data register when XR pin is used.
27 
28******************************************************************************
29 
30It is not clear in the documentation as to which settings will reset the device.
2031   To be safe, we will always reset whenever the control register changes.
2132 
2233   Also, it not clear exactly what happens under various error conditions.
r2830r2831
3142 
3243   The bit order of the status and control registers is set up to suit the
3344   Exidy driver. If you wish to use it for some other driver, use the BITSWAP8
34   macro in the driver.
45   macro in your driver.
3546 
47********************************************************************************
48 
3649Device Data:
3750 
3851* Common Controls:
3952-- Pin 1 - Vcc - 5 volts
40-- Pin 2 - not used
53-- Pin 2 - not used (on AY-5-1013 and AY-6-1013 this is Voo = -12 volts)
4154-- Pin 3 - Gnd - 0 volts
4255-- Pin 21 - XR - External Reset - resets all registers to initial state except for the control register
4356-- Pin 35 - NP - No Parity - "1" will kill any parity processing
r2830r2831
150163 
151164 
152165/*-------------------------------------------------
166    ay51013_xr - the reset pin
167-------------------------------------------------*/
168static void ay51013_xr( void )
169{
170   /* total pulses = 16 * data-bits */
171   UINT8 t1;
172   t1 = (ay.control_reg & 3) + 5;               /* data bits */
173   ay.total_pulses = t1 << 4;               /* total clock pulses to load a byte */
174   ay.second_stop_bit = ((ay.control_reg & AY31015_TSB) ? 16 : 0);      /* 2nd stop bit */
175   ay.status_reg = AY31015_EOC | AY31015_TBMT | AY31015_SO;
176   ay.tx_data = 0;
177   ay.rx_state = PREP_TIME;
178   ay.tx_state = IDLE;
179   ay.si = 1;
180}
181 
182 
183/*-------------------------------------------------
184    ay51013_init - drivers should call this at
185    machine reset time
186-------------------------------------------------*/
187void ay51013_init( void )
188{
189   ay.control_reg = 0;
190   ay.rx_data = 0;
191   ay51013_xr();
192}
193 
194 
195/*-------------------------------------------------
196    ay51013_cs - The entire control register is
197    updated at once.
198-------------------------------------------------*/
199void ay51013_cs( UINT8 data )
200{
201   UINT8 t1 = ay.control_reg;
202   ay.control_reg = data;
203   if (ay.control_reg != t1) ay51013_xr();
204}
205 
206 
207 
208/*-------------------------------------------------
153209    ay31015_xr - the reset pin
154210-------------------------------------------------*/
155211static void ay31015_xr( void )
r2830r2831
158214   UINT8 t1;
159215   t1 = (ay.control_reg & 3) + 5;               /* data bits */
160216   ay.total_pulses = t1 << 4;               /* total clock pulses to load a byte */
161   ay.second_stop_bit = ((ay.control_reg & AY31015_TSB) ? 1 : 0) << 4;      /* 2nd stop bit */
217   ay.second_stop_bit = ((ay.control_reg & AY31015_TSB) ? 16 : 0);      /* 2nd stop bit */
162218   if ((t1 == 5) && (ay.second_stop_bit == 16))
163219      ay.second_stop_bit = 8;            /* 5 data bits and 2 stop bits = 1.5 stop bits */
164220   ay.status_reg = AY31015_EOC | AY31015_TBMT | AY31015_SO;
r2830r2831
320376//            if (ay.second_stop_bit)
321377//            {
322378//               ay.rx_state = SECOND_STOP_BIT;
323//               ay.rx_pulses = ay.second_stop_bit - 2;
379//               ay.rx_pulses = ay.second_stop_bit;
324380//            }
325381//            else
326382//               ay.rx_state = PREP_TIME;
src/mess/machine/ay31015.h
r2830r2831
2222#define AY31015_SO   0x40
2323 
2424// Reset the device
25void ay51013_init( void );
26 
27// Set Control register
28void ay51013_cs( UINT8 data );
29 
30// Reset the device
2531void ay31015_init( void );
2632 
2733// Set Control register

Previous 15994 Revisions Next


© 1998-2018 The MESS Team