src/mess/machine/ay31015.c
| r2830 | r2831 | |
| 2 | 2 | |
| 3 | 3 | ay31015.c by Robbbert, May 2008
|
| 4 | 4 | |
| 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
|
| 6 | 6 | |
| 7 | 7 | This is cycle-accurate according to the specifications.
|
| 8 | 8 | |
| r2830 | r2831 | |
| 13 | 13 | |
| 14 | 14 | - If you find bugs, please fix them yourself.
|
| 15 | 15 | - 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.
|
| 16 | 17 | |
| 17 | | ****************************************************************************/
|
| 18 | *****************************************************************************
|
| 18 | 19 | |
| 19 | | /* It is not clear in the documentation as to which settings will reset the device.
|
| 20 | Differences 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 | |
| 30 | It is not clear in the documentation as to which settings will reset the device.
|
| 20 | 31 | To be safe, we will always reset whenever the control register changes.
|
| 21 | 32 | |
| 22 | 33 | Also, it not clear exactly what happens under various error conditions.
|
| r2830 | r2831 | |
| 31 | 42 | |
| 32 | 43 | The bit order of the status and control registers is set up to suit the
|
| 33 | 44 | 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.
|
| 35 | 46 | |
| 47 | ********************************************************************************
|
| 48 | |
| 36 | 49 | Device Data:
|
| 37 | 50 | |
| 38 | 51 | * Common Controls:
|
| 39 | 52 | -- 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)
|
| 41 | 54 | -- Pin 3 - Gnd - 0 volts
|
| 42 | 55 | -- Pin 21 - XR - External Reset - resets all registers to initial state except for the control register
|
| 43 | 56 | -- Pin 35 - NP - No Parity - "1" will kill any parity processing
|
| r2830 | r2831 | |
| 150 | 163 | |
| 151 | 164 | |
| 152 | 165 | /*-------------------------------------------------
|
| 166 | ay51013_xr - the reset pin
|
| 167 | -------------------------------------------------*/
|
| 168 | static 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 | -------------------------------------------------*/
|
| 187 | void 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 | -------------------------------------------------*/
|
| 199 | void 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 | /*-------------------------------------------------
|
| 153 | 209 | ay31015_xr - the reset pin
|
| 154 | 210 | -------------------------------------------------*/
|
| 155 | 211 | static void ay31015_xr( void )
|
| r2830 | r2831 | |
| 158 | 214 | UINT8 t1;
|
| 159 | 215 | t1 = (ay.control_reg & 3) + 5; /* data bits */
|
| 160 | 216 | 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 */
|
| 162 | 218 | if ((t1 == 5) && (ay.second_stop_bit == 16))
|
| 163 | 219 | ay.second_stop_bit = 8; /* 5 data bits and 2 stop bits = 1.5 stop bits */
|
| 164 | 220 | ay.status_reg = AY31015_EOC | AY31015_TBMT | AY31015_SO;
|
| r2830 | r2831 | |
| 320 | 376 | // if (ay.second_stop_bit)
|
| 321 | 377 | // {
|
| 322 | 378 | // ay.rx_state = SECOND_STOP_BIT;
|
| 323 | | // ay.rx_pulses = ay.second_stop_bit - 2;
|
| 379 | // ay.rx_pulses = ay.second_stop_bit;
|
| 324 | 380 | // }
|
| 325 | 381 | // else
|
| 326 | 382 | // ay.rx_state = PREP_TIME;
|