src/mess/machine/nmc9306.c
| r0 | r10589 | |
| 1 | /********************************************************************** |
| 2 | |
| 3 | National Semiconductor NMC9306 256-Bit Serial EEPROM emulation |
| 4 | |
| 5 | Copyright MESS Team. |
| 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | |
| 8 | **********************************************************************/ |
| 9 | |
| 10 | #include "emu.h" |
| 11 | #include "nmc9306.h" |
| 12 | #include "machine/devhelpr.h" |
| 13 | |
| 14 | |
| 15 | |
| 16 | //************************************************************************** |
| 17 | // MACROS / CONSTANTS |
| 18 | //************************************************************************** |
| 19 | |
| 20 | #define RAM_SIZE 32 |
| 21 | |
| 22 | |
| 23 | // instructions |
| 24 | enum |
| 25 | { |
| 26 | EWDS = 0, // erase/write disable |
| 27 | WRAL, // write all registers |
| 28 | ERAL, // erase all registers |
| 29 | EWEN, // erase/write enable |
| 30 | WRITE = 7, // write register A3A2A1A0 |
| 31 | READ, // read register A3A2A1A0 |
| 32 | ERASE // erase register A3A2A1A0 |
| 33 | }; |
| 34 | |
| 35 | |
| 36 | |
| 37 | //************************************************************************** |
| 38 | // DEVICE DEFINITIONS |
| 39 | //************************************************************************** |
| 40 | |
| 41 | const device_type NMC9306 = nmc9306_device_config::static_alloc_device_config; |
| 42 | |
| 43 | |
| 44 | |
| 45 | //************************************************************************** |
| 46 | // DEVICE CONFIGURATION |
| 47 | //************************************************************************** |
| 48 | |
| 49 | //------------------------------------------------- |
| 50 | // nmc9306_device_config - constructor |
| 51 | //------------------------------------------------- |
| 52 | |
| 53 | nmc9306_device_config::nmc9306_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) |
| 54 | : device_config(mconfig, static_alloc_device_config, "NMC9306", tag, owner, clock), |
| 55 | device_config_nvram_interface(mconfig, *this) |
| 56 | { |
| 57 | } |
| 58 | |
| 59 | |
| 60 | //------------------------------------------------- |
| 61 | // static_alloc_device_config - allocate a new |
| 62 | // configuration object |
| 63 | //------------------------------------------------- |
| 64 | |
| 65 | device_config *nmc9306_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) |
| 66 | { |
| 67 | return global_alloc(nmc9306_device_config(mconfig, tag, owner, clock)); |
| 68 | } |
| 69 | |
| 70 | |
| 71 | //------------------------------------------------- |
| 72 | // alloc_device - allocate a new device object |
| 73 | //------------------------------------------------- |
| 74 | |
| 75 | device_t *nmc9306_device_config::alloc_device(running_machine &machine) const |
| 76 | { |
| 77 | return auto_alloc(&machine, nmc9306_device(machine, *this)); |
| 78 | } |
| 79 | |
| 80 | |
| 81 | |
| 82 | //************************************************************************** |
| 83 | // LIVE DEVICE |
| 84 | //************************************************************************** |
| 85 | |
| 86 | //------------------------------------------------- |
| 87 | // nmc9306_device - constructor |
| 88 | //------------------------------------------------- |
| 89 | |
| 90 | nmc9306_device::nmc9306_device(running_machine &_machine, const nmc9306_device_config &config) |
| 91 | : device_t(_machine, config), |
| 92 | device_nvram_interface(_machine, config, *this), |
| 93 | m_config(config) |
| 94 | { |
| 95 | } |
| 96 | |
| 97 | |
| 98 | //------------------------------------------------- |
| 99 | // device_start - device-specific startup |
| 100 | //------------------------------------------------- |
| 101 | |
| 102 | void nmc9306_device::device_start() |
| 103 | { |
| 104 | } |
| 105 | |
| 106 | |
| 107 | //------------------------------------------------- |
| 108 | // nvram_default - called to initialize NVRAM to |
| 109 | // its default state |
| 110 | //------------------------------------------------- |
| 111 | |
| 112 | void nmc9306_device::nvram_default() |
| 113 | { |
| 114 | } |
| 115 | |
| 116 | |
| 117 | //------------------------------------------------- |
| 118 | // nvram_read - called to read NVRAM from the |
| 119 | // .nv file |
| 120 | //------------------------------------------------- |
| 121 | |
| 122 | void nmc9306_device::nvram_read(emu_file &file) |
| 123 | { |
| 124 | file.read(m_register, RAM_SIZE); |
| 125 | } |
| 126 | |
| 127 | |
| 128 | //------------------------------------------------- |
| 129 | // nvram_write - called to write NVRAM to the |
| 130 | // .nv file |
| 131 | //------------------------------------------------- |
| 132 | |
| 133 | void nmc9306_device::nvram_write(emu_file &file) |
| 134 | { |
| 135 | file.write(m_register, RAM_SIZE); |
| 136 | } |
| 137 | |
| 138 | |
| 139 | //------------------------------------------------- |
| 140 | // cs_w - chip select input |
| 141 | //------------------------------------------------- |
| 142 | |
| 143 | WRITE_LINE_MEMBER( nmc9306_device::cs_w ) |
| 144 | { |
| 145 | m_cs = state; |
| 146 | } |
| 147 | |
| 148 | |
| 149 | //------------------------------------------------- |
| 150 | // ck_w - serial clock input |
| 151 | //------------------------------------------------- |
| 152 | |
| 153 | WRITE_LINE_MEMBER( nmc9306_device::sk_w ) |
| 154 | { |
| 155 | m_sk = state; |
| 156 | } |
| 157 | |
| 158 | |
| 159 | //------------------------------------------------- |
| 160 | // di_w - serial data input |
| 161 | //------------------------------------------------- |
| 162 | |
| 163 | WRITE_LINE_MEMBER( nmc9306_device::di_w ) |
| 164 | { |
| 165 | m_di = state; |
| 166 | } |
| 167 | |
| 168 | |
| 169 | //------------------------------------------------- |
| 170 | // do_r - serial data output |
| 171 | //------------------------------------------------- |
| 172 | |
| 173 | READ_LINE_MEMBER( nmc9306_device::do_r ) |
| 174 | { |
| 175 | return m_do; |
| 176 | } |
src/mess/machine/nmc9306.h
| r0 | r10589 | |
| 1 | /********************************************************************** |
| 2 | |
| 3 | National Semiconductor NMC9306 256-Bit Serial EEPROM emulation |
| 4 | |
| 5 | Copyright MESS Team. |
| 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | |
| 8 | ********************************************************************** |
| 9 | _____ _____ |
| 10 | CS 1 |* \_/ | 8 Vcc |
| 11 | SK 2 | | 7 NC |
| 12 | DI 3 | | 6 NC |
| 13 | DO 4 |_____________| 5 GND |
| 14 | |
| 15 | **********************************************************************/ |
| 16 | |
| 17 | #pragma once |
| 18 | |
| 19 | #ifndef __NMC9306__ |
| 20 | #define __NMC9306__ |
| 21 | |
| 22 | #include "emu.h" |
| 23 | |
| 24 | |
| 25 | |
| 26 | //************************************************************************** |
| 27 | // MACROS / CONSTANTS |
| 28 | //************************************************************************** |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | //************************************************************************** |
| 34 | // INTERFACE CONFIGURATION MACROS |
| 35 | //************************************************************************** |
| 36 | |
| 37 | #define MCFG_NMC9306_ADD(_tag) \ |
| 38 | MCFG_DEVICE_ADD(_tag, NMC9306, 0) |
| 39 | |
| 40 | |
| 41 | |
| 42 | //************************************************************************** |
| 43 | // TYPE DEFINITIONS |
| 44 | //************************************************************************** |
| 45 | |
| 46 | |
| 47 | // ======================> nmc9306_device_config |
| 48 | |
| 49 | class nmc9306_device_config : public device_config, |
| 50 | public device_config_nvram_interface |
| 51 | { |
| 52 | friend class nmc9306_device; |
| 53 | |
| 54 | // construction/destruction |
| 55 | nmc9306_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); |
| 56 | |
| 57 | public: |
| 58 | // allocators |
| 59 | static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); |
| 60 | virtual device_t *alloc_device(running_machine &machine) const; |
| 61 | |
| 62 | protected: |
| 63 | }; |
| 64 | |
| 65 | |
| 66 | // ======================> nmc9306_device |
| 67 | |
| 68 | class nmc9306_device : public device_t, |
| 69 | public device_nvram_interface |
| 70 | { |
| 71 | friend class nmc9306_device_config; |
| 72 | |
| 73 | // construction/destruction |
| 74 | nmc9306_device(running_machine &_machine, const nmc9306_device_config &_config); |
| 75 | |
| 76 | public: |
| 77 | DECLARE_WRITE_LINE_MEMBER( cs_w ); |
| 78 | DECLARE_WRITE_LINE_MEMBER( sk_w ); |
| 79 | DECLARE_WRITE_LINE_MEMBER( di_w ); |
| 80 | DECLARE_READ_LINE_MEMBER( do_r ); |
| 81 | |
| 82 | protected: |
| 83 | // device-level overrides |
| 84 | virtual void device_start(); |
| 85 | |
| 86 | // device_nvram_interface overrides |
| 87 | virtual void nvram_default(); |
| 88 | virtual void nvram_read(emu_file &file); |
| 89 | virtual void nvram_write(emu_file &file); |
| 90 | |
| 91 | private: |
| 92 | UINT16 m_register[16]; |
| 93 | |
| 94 | int m_cs; |
| 95 | int m_sk; |
| 96 | int m_do; |
| 97 | int m_di; |
| 98 | int m_a; |
| 99 | |
| 100 | const nmc9306_device_config &m_config; |
| 101 | }; |
| 102 | |
| 103 | |
| 104 | // device type definition |
| 105 | extern const device_type NMC9306; |
| 106 | |
| 107 | |
| 108 | |
| 109 | #endif |
src/mess/drivers/abc1600.c
| r10588 | r10589 | |
| 38 | 38 | #include "machine/8530scc.h" |
| 39 | 39 | #include "machine/abc99.h" |
| 40 | 40 | #include "machine/e0516.h" |
| 41 | #include "machine/nmc9306.h" |
| 41 | 42 | #include "machine/s1410.h" |
| 42 | 43 | #include "machine/wd17xx.h" |
| 43 | 44 | #include "machine/z80dart.h" |
| r10588 | r10589 | |
| 384 | 385 | |
| 385 | 386 | */ |
| 386 | 387 | |
| 388 | UINT8 data = 0; |
| 389 | |
| 390 | // data in |
| 391 | data |= (e0516_dio_r(m_rtc) | m_nvram->do_r()) << 1; |
| 392 | |
| 387 | 393 | return 0; |
| 388 | 394 | } |
| 389 | 395 | |
| r10588 | r10589 | |
| 395 | 401 | |
| 396 | 402 | PC0 CLOCK |
| 397 | 403 | PC1 DATA OUT |
| 398 | | PC2 enable RTC |
| 399 | | PC3 enable NVRAM |
| 404 | PC2 RTC CS |
| 405 | PC3 NVRAM CS |
| 400 | 406 | |
| 401 | 407 | */ |
| 408 | |
| 409 | int clock = BIT(data, 0); |
| 410 | int data_out = BIT(data, 1); |
| 411 | int rtc_cs = BIT(data, 2); |
| 412 | int nvram_cs = BIT(data, 3); |
| 413 | |
| 414 | e0516_cs_w(m_rtc, rtc_cs); |
| 415 | e0516_dio_w(m_rtc, data_out); |
| 416 | e0516_clk_w(m_rtc, clock); |
| 417 | |
| 418 | m_nvram->cs_w(nvram_cs); |
| 419 | m_nvram->di_w(data_out); |
| 420 | m_nvram->sk_w(clock); |
| 402 | 421 | } |
| 403 | 422 | |
| 404 | 423 | static Z8536_INTERFACE( cio_intf ) |
| r10588 | r10589 | |
| 496 | 515 | MCFG_Z80DART_ADD(Z8470AB1_TAG, XTAL_64MHz/16, dart_intf) |
| 497 | 516 | MCFG_SCC8530_ADD(Z8530B1_TAG, XTAL_64MHz/16) |
| 498 | 517 | MCFG_Z8536_ADD(Z8536B1_TAG, XTAL_64MHz/16, cio_intf) |
| 499 | | // MCFG_NMC9306_ADD(NMC9306_TAG) |
| 518 | MCFG_NMC9306_ADD(NMC9306_TAG) |
| 500 | 519 | MCFG_E0516_ADD(E050_C16PC_TAG, XTAL_32_768kHz) |
| 501 | 520 | MCFG_WD179X_ADD(SAB1797_02P_TAG, fdc_intf) |
| 502 | 521 | MCFG_FLOPPY_DRIVE_ADD(FLOPPY_0, abc1600_floppy_config) |