From f9e01252469acd9f9216c5300b125dd80703ebdc Mon Sep 17 00:00:00 2001 From: Curt Coder Date: Sat, 9 Apr 2011 12:01:11 +0000 Subject: [PATCH] Imported UPD7201 MPSC from MESS. (no whatsnew) --- .gitattributes | 2 + src/emu/emu.mak | 1 + src/emu/machine/upd7201.c | 347 ++++++++++++++++++++++++++++++++++++++ src/emu/machine/upd7201.h | 175 +++++++++++++++++++ 4 files changed, 525 insertions(+) create mode 100644 src/emu/machine/upd7201.c create mode 100644 src/emu/machine/upd7201.h diff --git a/.gitattributes b/.gitattributes index 71ac0b15744..d0c5096de38 100644 --- a/.gitattributes +++ b/.gitattributes @@ -883,6 +883,8 @@ src/emu/machine/upd1990a.c svneol=native#text/plain src/emu/machine/upd1990a.h svneol=native#text/plain src/emu/machine/upd4701.c svneol=native#text/plain src/emu/machine/upd4701.h svneol=native#text/plain +src/emu/machine/upd7201.c svneol=native#text/plain +src/emu/machine/upd7201.h svneol=native#text/plain src/emu/machine/wd33c93.c svneol=native#text/plain src/emu/machine/wd33c93.h svneol=native#text/plain src/emu/machine/x2212.c svneol=native#text/plain diff --git a/src/emu/emu.mak b/src/emu/emu.mak index 0cd5b4ad9eb..25b0926fc9d 100644 --- a/src/emu/emu.mak +++ b/src/emu/emu.mak @@ -217,6 +217,7 @@ EMUMACHINEOBJS = \ $(EMUMACHINE)/tms6100.o \ $(EMUMACHINE)/upd1990a.o \ $(EMUMACHINE)/upd4701.o \ + $(EMUMACHINE)/upd7201.o \ $(EMUMACHINE)/wd33c93.o \ $(EMUMACHINE)/x2212.o \ $(EMUMACHINE)/x76f041.o \ diff --git a/src/emu/machine/upd7201.c b/src/emu/machine/upd7201.c new file mode 100644 index 00000000000..84968bb4eec --- /dev/null +++ b/src/emu/machine/upd7201.c @@ -0,0 +1,347 @@ +/********************************************************************** + + NEC uPD7201 Multiprotocol Serial Communications Controller + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +**********************************************************************/ + +/* + + TODO: + + - this is a clone of Intel 8274? + - everything + +*/ + +#include "emu.h" +#include "upd7201.h" +#include "machine/devhelpr.h" + + + +//************************************************************************** +// MACROS / CONSTANTS +//************************************************************************** + +#define LOG 0 + + +enum +{ + CHANNEL_A = 0, + CHANNEL_B +}; + + + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +// devices +const device_type UPD7201 = upd7201_device_config::static_alloc_device_config; + + + +//************************************************************************** +// DEVICE CONFIGURATION +//************************************************************************** + +GENERIC_DEVICE_CONFIG_SETUP(upd7201, "UPD7201") + + +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- + +void upd7201_device_config::device_config_complete() +{ + // inherit a copy of the static data + const upd7201_interface *intf = reinterpret_cast(static_config()); + if (intf != NULL) + *static_cast(this) = *intf; + + // or initialize to defaults if none provided + else + { + memset(&m_out_int_func, 0, sizeof(m_out_int_func)); + } +} + + + +//************************************************************************** +// INLINE HELPERS +//************************************************************************** + +//------------------------------------------------- +// receive - +//------------------------------------------------- + +inline void upd7201_device::receive(int channel) +{ +} + + +//------------------------------------------------- +// transmit - +//------------------------------------------------- + +inline void upd7201_device::transmit(int channel) +{ +} + + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// upd7201_device - constructor +//------------------------------------------------- + +upd7201_device::upd7201_device(running_machine &_machine, const upd7201_device_config &config) + : device_t(_machine, config), + m_config(config) +{ +} + + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void upd7201_device::device_start() +{ + // resolve callbacks + devcb_resolve_write_line(&m_out_int_func, &m_config.m_out_int_func, this); +} + + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void upd7201_device::device_reset() +{ +} + + +//------------------------------------------------- +// device_timer - handler timer events +//------------------------------------------------- + +void upd7201_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +{ + switch (id) + { + case TIMER_RX_A: + receive(CHANNEL_A); + break; + + case TIMER_TX_A: + transmit(CHANNEL_A); + break; + + case TIMER_RX_B: + receive(CHANNEL_B); + break; + + case TIMER_TX_B: + transmit(CHANNEL_B); + break; + } +} + + +//------------------------------------------------- +// cd_ba_r - +//------------------------------------------------- + +READ8_MEMBER( upd7201_device::cd_ba_r ) +{ + return 0; +} + + +//------------------------------------------------- +// cd_ba_w - +//------------------------------------------------- + +WRITE8_MEMBER( upd7201_device::cd_ba_w ) +{ +} + + +//------------------------------------------------- +// ba_cd_r - +//------------------------------------------------- + +READ8_MEMBER( upd7201_device::ba_cd_r ) +{ + return 0; +} + + +//------------------------------------------------- +// ba_cd_w - +//------------------------------------------------- + +WRITE8_MEMBER( upd7201_device::ba_cd_w ) +{ +} + + +//------------------------------------------------- +// intak_r - +//------------------------------------------------- + +READ8_MEMBER( upd7201_device::intak_r ) +{ + return 0; +} + + +//------------------------------------------------- +// synca_w - +//------------------------------------------------- + +WRITE_LINE_MEMBER( upd7201_device::synca_w ) +{ +} + + +//------------------------------------------------- +// syncb_w - +//------------------------------------------------- + +WRITE_LINE_MEMBER( upd7201_device::syncb_w ) +{ +} + + +//------------------------------------------------- +// ctsa_w - +//------------------------------------------------- + +WRITE_LINE_MEMBER( upd7201_device::ctsa_w ) +{ +} + + +//------------------------------------------------- +// ctsb_w - +//------------------------------------------------- + +WRITE_LINE_MEMBER( upd7201_device::ctsb_w ) +{ +} + + +//------------------------------------------------- +// dtra_r - +//------------------------------------------------- + +READ_LINE_MEMBER( upd7201_device::dtra_r ) +{ + return 0; +} + + +//------------------------------------------------- +// dtrb_r - +//------------------------------------------------- + +READ_LINE_MEMBER( upd7201_device::dtrb_r ) +{ + return 0; +} + + +//------------------------------------------------- +// hai_w - +//------------------------------------------------- + +WRITE_LINE_MEMBER( upd7201_device::hai_w ) +{ +} + + +//------------------------------------------------- +// rxda_w - +//------------------------------------------------- + +WRITE_LINE_MEMBER( upd7201_device::rxda_w ) +{ +} + + +//------------------------------------------------- +// txda_r - +//------------------------------------------------- + +READ_LINE_MEMBER( upd7201_device::txda_r ) +{ + return 0; +} + + +//------------------------------------------------- +// rxdb_w - +//------------------------------------------------- + +WRITE_LINE_MEMBER( upd7201_device::rxdb_w ) +{ +} + + +//------------------------------------------------- +// txdb_r - +//------------------------------------------------- + +READ_LINE_MEMBER( upd7201_device::txdb_r ) +{ + return 0; +} + + +//------------------------------------------------- +// rxca_w - +//------------------------------------------------- + +WRITE_LINE_MEMBER( upd7201_device::rxca_w ) +{ +} + + +//------------------------------------------------- +// rxcb_w - +//------------------------------------------------- + +WRITE_LINE_MEMBER( upd7201_device::rxcb_w ) +{ +} + + +//------------------------------------------------- +// txca_w - +//------------------------------------------------- + +WRITE_LINE_MEMBER( upd7201_device::txca_w ) +{ +} + + +//------------------------------------------------- +// txcb_w - +//------------------------------------------------- + +WRITE_LINE_MEMBER( upd7201_device::txcb_w ) +{ +} diff --git a/src/emu/machine/upd7201.h b/src/emu/machine/upd7201.h new file mode 100644 index 00000000000..40ebaa75ebb --- /dev/null +++ b/src/emu/machine/upd7201.h @@ -0,0 +1,175 @@ +/********************************************************************** + + NEC uPD7201 Multiprotocol Serial Communications Controller + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + +********************************************************************** + _____ _____ + CLK 1 |* \_/ | 40 Vcc + _RESET 2 | | 39 _CTSA + _DCDA 3 | | 38 _RTSA + _RxCB 4 | | 37 TxDA + _DCDB 5 | | 36 _TxCA + _CTSB 6 | | 35 _RxCA + _TxCB 7 | | 34 RxDA + TxDB 8 | | 33 _SYNCA + RxDB 9 | | 32 _WAITA/DRQRxA + _RTSB/_SYNCB 10 | UPD7201 | 31 _DTRA/_HAO + _WAITB/_DRQTxA 11 | | 30 _PRO/DRQTxB + D7 12 | | 29 _PRI/DRQRxB + D6 13 | | 28 _INT + D5 14 | | 27 _INTAK + D4 15 | | 26 _DTRB/_HAI + D3 16 | | 25 B/_A + D2 17 | | 24 C/_D + D1 18 | | 23 _CS + D0 19 | | 22 _RD + Vss 20 |_____________| 21 _WR + +**********************************************************************/ + +#pragma once + +#ifndef __UPD7201__ +#define __UPD7201__ + +#include "emu.h" + + + +//************************************************************************** +// INTERFACE CONFIGURATION MACROS +//************************************************************************** + +#define MCFG_UPD7201_ADD(_tag, _clock, _config) \ + MCFG_DEVICE_ADD((_tag), UPD7201, _clock) \ + MCFG_DEVICE_CONFIG(_config) + +#define UPD7201_INTERFACE(name) \ + const upd7201_interface (name) = + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> upd7201_interface + +struct upd7201_interface +{ + devcb_write_line m_out_int_func; + + struct + { + int m_rx_clock; + int m_tx_clock; + + devcb_write_line m_out_drqrx_func; + devcb_write_line m_out_drqtx_func; + + devcb_read_line m_in_rxd_func; + devcb_write_line m_out_txd_func; + + devcb_read_line m_in_cts_func; + devcb_read_line m_in_dcd_func; + devcb_write_line m_out_rts_func; + devcb_write_line m_out_dtr_func; + + devcb_write_line m_out_wait_func; + devcb_write_line m_out_sync_func; + } m_channel[2]; +}; + + + +// ======================> upd7201_device_config + +class upd7201_device_config : public device_config, + public upd7201_interface +{ + friend class upd7201_device; + + // construction/destruction + upd7201_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + +public: + // allocators + static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + virtual device_t *alloc_device(running_machine &machine) const; + +protected: + // device_config overrides + virtual void device_config_complete(); +}; + + + +// ======================> upd7201_device + +class upd7201_device : public device_t +{ + friend class upd7201_device_config; + + // construction/destruction + upd7201_device(running_machine &_machine, const upd7201_device_config &_config); + +public: + DECLARE_READ8_MEMBER( cd_ba_r ); + DECLARE_WRITE8_MEMBER( cd_ba_w ); + DECLARE_READ8_MEMBER( ba_cd_r ); + DECLARE_WRITE8_MEMBER( ba_cd_w ); + + DECLARE_READ8_MEMBER( intak_r ); + + DECLARE_WRITE_LINE_MEMBER( synca_w ); + DECLARE_WRITE_LINE_MEMBER( syncb_w ); + DECLARE_WRITE_LINE_MEMBER( ctsa_w ); + DECLARE_WRITE_LINE_MEMBER( ctsb_w ); + DECLARE_READ_LINE_MEMBER( dtra_r ); + DECLARE_READ_LINE_MEMBER( dtrb_r ); + DECLARE_WRITE_LINE_MEMBER( hai_w ); + DECLARE_WRITE_LINE_MEMBER( rxda_w ); + DECLARE_READ_LINE_MEMBER( txda_r ); + DECLARE_WRITE_LINE_MEMBER( rxdb_w ); + DECLARE_READ_LINE_MEMBER( txdb_r ); + DECLARE_WRITE_LINE_MEMBER( rxca_w ); + DECLARE_WRITE_LINE_MEMBER( rxcb_w ); + DECLARE_WRITE_LINE_MEMBER( txca_w ); + DECLARE_WRITE_LINE_MEMBER( txcb_w ); + +protected: + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + virtual void device_timer(emu_timer &timer, device_timer_id id, int m_param, void *ptr); + +private: + static const device_timer_id TIMER_RX_A = 0; + static const device_timer_id TIMER_TX_A = 1; + static const device_timer_id TIMER_RX_B = 2; + static const device_timer_id TIMER_TX_B = 3; + + inline void receive(int channel); + inline void transmit(int channel); + + devcb_resolved_write_line m_out_int_func; + + // timers + emu_timer *m_rx_a_timer; + emu_timer *m_tx_a_timer; + emu_timer *m_rx_b_timer; + emu_timer *m_tx_b_timer; + + const upd7201_device_config &m_config; +}; + + +// device type definition +extern const device_type UPD7201; + + + +#endif