mirror of
https://github.com/holub/mame
synced 2025-07-05 09:57:47 +03:00
(MESS) modernized DS1315 clock device. [Fabio Priuli]
This commit is contained in:
parent
f9d591b7bc
commit
6c1b85e1aa
@ -71,7 +71,6 @@
|
|||||||
#include "imagedev/flopdrv.h"
|
#include "imagedev/flopdrv.h"
|
||||||
#include "includes/coco.h"
|
#include "includes/coco.h"
|
||||||
#include "machine/wd17xx.h"
|
#include "machine/wd17xx.h"
|
||||||
#include "machine/ds1315.h"
|
|
||||||
#include "imagedev/flopdrv.h"
|
#include "imagedev/flopdrv.h"
|
||||||
#include "formats/coco_dsk.h"
|
#include "formats/coco_dsk.h"
|
||||||
|
|
||||||
@ -207,7 +206,7 @@ void coco_fdc_device::device_start()
|
|||||||
m_owner = dynamic_cast<cococart_slot_device *>(owner());
|
m_owner = dynamic_cast<cococart_slot_device *>(owner());
|
||||||
m_drq = 1;
|
m_drq = 1;
|
||||||
m_disto_msm6242 = subdevice<msm6242_device>(DISTO_TAG);
|
m_disto_msm6242 = subdevice<msm6242_device>(DISTO_TAG);
|
||||||
m_ds1315 = subdevice(CLOUD9_TAG);
|
m_ds1315 = subdevice<ds1315_device>(CLOUD9_TAG);
|
||||||
m_wd17xx = subdevice(WD_TAG);
|
m_wd17xx = subdevice(WD_TAG);
|
||||||
m_dskreg = 0x00;
|
m_dskreg = 0x00;
|
||||||
m_intrq = 0;
|
m_intrq = 0;
|
||||||
@ -359,17 +358,17 @@ READ8_MEMBER(coco_fdc_device::read)
|
|||||||
|
|
||||||
case 0x38: /* FF78 */
|
case 0x38: /* FF78 */
|
||||||
if (real_time_clock() == RTC_CLOUD9)
|
if (real_time_clock() == RTC_CLOUD9)
|
||||||
ds1315_r_0(m_ds1315, space, offset);
|
m_ds1315->read_0(space, offset);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x39: /* FF79 */
|
case 0x39: /* FF79 */
|
||||||
if (real_time_clock() == RTC_CLOUD9)
|
if (real_time_clock() == RTC_CLOUD9)
|
||||||
ds1315_r_1(m_ds1315, space, offset);
|
m_ds1315->read_1(space, offset);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x3C: /* FF7C */
|
case 0x3C: /* FF7C */
|
||||||
if (real_time_clock() == RTC_CLOUD9)
|
if (real_time_clock() == RTC_CLOUD9)
|
||||||
result = ds1315_r_data(m_ds1315, space, offset);
|
result = m_ds1315->read_data(space, offset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "emu.h"
|
#include "emu.h"
|
||||||
#include "machine/cococart.h"
|
#include "machine/cococart.h"
|
||||||
#include "machine/msm6242.h"
|
#include "machine/msm6242.h"
|
||||||
|
#include "machine/ds1315.h"
|
||||||
|
|
||||||
//**************************************************************************
|
//**************************************************************************
|
||||||
// TYPE DEFINITIONS
|
// TYPE DEFINITIONS
|
||||||
@ -59,7 +60,7 @@ protected:
|
|||||||
UINT8 m_intrq : 1;
|
UINT8 m_intrq : 1;
|
||||||
|
|
||||||
device_t *m_wd17xx; /* WD17xx */
|
device_t *m_wd17xx; /* WD17xx */
|
||||||
device_t *m_ds1315; /* DS1315 */
|
ds1315_device *m_ds1315; /* DS1315 */
|
||||||
|
|
||||||
/* Disto RTC */
|
/* Disto RTC */
|
||||||
msm6242_device *m_disto_msm6242; /* 6242 RTC on Disto interface */
|
msm6242_device *m_disto_msm6242; /* 6242 RTC on Disto interface */
|
||||||
|
@ -11,23 +11,43 @@
|
|||||||
#include "ds1315.h"
|
#include "ds1315.h"
|
||||||
#include "coreutil.h"
|
#include "coreutil.h"
|
||||||
|
|
||||||
/***************************************************************************
|
|
||||||
TYPE DEFINITIONS
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
enum ds1315_mode_t
|
const device_type DS1315 = &device_creator<ds1315_device>;
|
||||||
|
|
||||||
|
ds1315_device::ds1315_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||||
|
: device_t(mconfig, DS1315, "Dallas Semiconductor DS1315", tag, owner, clock)
|
||||||
{
|
{
|
||||||
DS_SEEK_MATCHING,
|
}
|
||||||
DS_CALENDAR_IO
|
|
||||||
};
|
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// device_config_complete - perform any
|
||||||
|
// operations now that the configuration is
|
||||||
|
// complete
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
struct ds1315_t
|
void ds1315_device::device_config_complete()
|
||||||
{
|
{
|
||||||
int count;
|
}
|
||||||
ds1315_mode_t mode;
|
|
||||||
UINT8 raw_data[8*8];
|
//-------------------------------------------------
|
||||||
};
|
// device_start - device-specific startup
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
void ds1315_device::device_start()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// device_reset - device-specific reset
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
void ds1315_device::device_reset()
|
||||||
|
{
|
||||||
|
memset(m_raw_data, 0, sizeof(m_raw_data));
|
||||||
|
m_count = 0;
|
||||||
|
m_mode = DS_SEEK_MATCHING;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
@ -47,160 +67,117 @@ static const UINT8 ds1315_pattern[] =
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
|
||||||
PROTOTYPES
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
static void ds1315_fill_raw_data(device_t *device);
|
|
||||||
static void ds1315_input_raw_data(device_t *device);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
|
||||||
INLINE FUNCTIONS
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
INLINE ds1315_t *get_token(device_t *device)
|
|
||||||
{
|
|
||||||
assert(device != NULL);
|
|
||||||
assert(device->type() == DS1315);
|
|
||||||
return (ds1315_t *) downcast<ds1315_device *>(device)->token();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
IMPLEMENTATION
|
IMPLEMENTATION
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
DEVICE_START( ds1315 )
|
read_0
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
static DEVICE_START(ds1315)
|
READ8_MEMBER( ds1315_device::read_0 )
|
||||||
{
|
{
|
||||||
ds1315_t *ds1315 = get_token(device);
|
if (ds1315_pattern[m_count++] == 0)
|
||||||
|
|
||||||
memset(ds1315, 0, sizeof(*ds1315));
|
|
||||||
ds1315->count = 0;
|
|
||||||
ds1315->mode = DS_SEEK_MATCHING;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
|
||||||
DEVICE_START( ds1315 )
|
|
||||||
-------------------------------------------------*/
|
|
||||||
|
|
||||||
READ8_DEVICE_HANDLER( ds1315_r_0 )
|
|
||||||
{
|
|
||||||
ds1315_t *ds1315 = get_token(device);
|
|
||||||
|
|
||||||
if (ds1315_pattern[ds1315->count++] == 0)
|
|
||||||
{
|
{
|
||||||
if (ds1315->count == 64)
|
if (m_count == 64)
|
||||||
{
|
{
|
||||||
/* entire pattern matched */
|
/* entire pattern matched */
|
||||||
ds1315->count = 0;
|
m_count = 0;
|
||||||
ds1315->mode = DS_CALENDAR_IO;
|
m_mode = DS_CALENDAR_IO;
|
||||||
ds1315_fill_raw_data(device);
|
fill_raw_data();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ds1315->count = 0;
|
m_count = 0;
|
||||||
ds1315->mode = DS_SEEK_MATCHING;
|
m_mode = DS_SEEK_MATCHING;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
ds1315_r_1
|
read_1
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
READ8_DEVICE_HANDLER ( ds1315_r_1 )
|
READ8_MEMBER( ds1315_device::read_1 )
|
||||||
{
|
{
|
||||||
ds1315_t *ds1315 = get_token(device);
|
if (ds1315_pattern[m_count++] == 1)
|
||||||
|
|
||||||
if (ds1315_pattern[ ds1315->count++ ] == 1)
|
|
||||||
{
|
{
|
||||||
ds1315->count %= 64;
|
m_count %= 64;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ds1315->count = 0;
|
m_count = 0;
|
||||||
ds1315->mode = DS_SEEK_MATCHING;
|
m_mode = DS_SEEK_MATCHING;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
ds1315_r_data
|
read_data
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
READ8_DEVICE_HANDLER ( ds1315_r_data )
|
READ8_MEMBER( ds1315_device::read_data )
|
||||||
{
|
{
|
||||||
UINT8 result;
|
UINT8 result;
|
||||||
ds1315_t *ds1315 = get_token(device);
|
|
||||||
|
|
||||||
if (ds1315->mode == DS_CALENDAR_IO)
|
if (m_mode == DS_CALENDAR_IO)
|
||||||
{
|
{
|
||||||
result = ds1315->raw_data[ ds1315->count++ ];
|
result = m_raw_data[m_count++];
|
||||||
|
|
||||||
if (ds1315->count == 64)
|
if (m_count == 64)
|
||||||
{
|
{
|
||||||
ds1315->mode = DS_SEEK_MATCHING;
|
m_mode = DS_SEEK_MATCHING;
|
||||||
ds1315->count = 0;
|
m_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ds1315->count = 0;
|
m_count = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
ds1315_w_data
|
write_data
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
WRITE8_DEVICE_HANDLER ( ds1315_w_data )
|
WRITE8_MEMBER( ds1315_device::write_data )
|
||||||
{
|
{
|
||||||
ds1315_t *ds1315 = get_token(device);
|
if (m_mode == DS_CALENDAR_IO)
|
||||||
|
|
||||||
if (ds1315->mode == DS_CALENDAR_IO)
|
|
||||||
{
|
{
|
||||||
ds1315->raw_data[ds1315->count++] = data & 0x01;
|
m_raw_data[m_count++] = data & 0x01;
|
||||||
|
|
||||||
if (ds1315->count == 64)
|
if (m_count == 64)
|
||||||
{
|
{
|
||||||
ds1315->mode = DS_SEEK_MATCHING;
|
m_mode = DS_SEEK_MATCHING;
|
||||||
ds1315->count = 0;
|
m_count = 0;
|
||||||
ds1315_input_raw_data(device);
|
input_raw_data();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ds1315->count = 0;
|
m_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
ds1315_fill_raw_data
|
fill_raw_data
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
static void ds1315_fill_raw_data(device_t *device)
|
void ds1315_device::fill_raw_data()
|
||||||
{
|
{
|
||||||
/* This routine will (hopefully) call a standard 'C' library routine to get the current
|
/* This routine will (hopefully) call a standard 'C' library routine to get the current
|
||||||
date and time and then fill in the raw data struct.
|
date and time and then fill in the raw data struct.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
system_time systime;
|
system_time systime;
|
||||||
ds1315_t *ds1315 = get_token(device);
|
|
||||||
int raw[8], i, j;
|
int raw[8], i, j;
|
||||||
|
|
||||||
/* get the current date/time from the core */
|
/* get the current date/time from the core */
|
||||||
device->machine().current_datetime(systime);
|
machine().current_datetime(systime);
|
||||||
|
|
||||||
raw[0] = 0; /* tenths and hundreths of seconds are always zero */
|
raw[0] = 0; /* tenths and hundreths of seconds are always zero */
|
||||||
raw[1] = dec_2_bcd(systime.local_time.second);
|
raw[1] = dec_2_bcd(systime.local_time.second);
|
||||||
@ -217,7 +194,7 @@ static void ds1315_fill_raw_data(device_t *device)
|
|||||||
for (i = 0; i < 64; i++)
|
for (i = 0; i < 64; i++)
|
||||||
{
|
{
|
||||||
j = i / 8;
|
j = i / 8;
|
||||||
ds1315->raw_data[i] = (raw[j] & 0x0001);
|
m_raw_data[i] = (raw[j] & 0x0001);
|
||||||
raw[j] = raw[j] >> 1;
|
raw[j] = raw[j] >> 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -227,7 +204,7 @@ static void ds1315_fill_raw_data(device_t *device)
|
|||||||
ds1315_input_raw_data
|
ds1315_input_raw_data
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
static void ds1315_input_raw_data(device_t *device)
|
void ds1315_device::input_raw_data()
|
||||||
{
|
{
|
||||||
/* This routine is called when new date and time has been written to the
|
/* This routine is called when new date and time has been written to the
|
||||||
clock chip. Currently we ignore setting the date and time in the clock
|
clock chip. Currently we ignore setting the date and time in the clock
|
||||||
@ -238,29 +215,3 @@ static void ds1315_input_raw_data(device_t *device)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const device_type DS1315 = &device_creator<ds1315_device>;
|
|
||||||
|
|
||||||
ds1315_device::ds1315_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
|
||||||
: device_t(mconfig, DS1315, "Dallas Semiconductor DS1315", tag, owner, clock)
|
|
||||||
{
|
|
||||||
m_token = global_alloc_clear(ds1315_t);
|
|
||||||
}
|
|
||||||
|
|
||||||
//-------------------------------------------------
|
|
||||||
// device_config_complete - perform any
|
|
||||||
// operations now that the configuration is
|
|
||||||
// complete
|
|
||||||
//-------------------------------------------------
|
|
||||||
|
|
||||||
void ds1315_device::device_config_complete()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//-------------------------------------------------
|
|
||||||
// device_start - device-specific startup
|
|
||||||
//-------------------------------------------------
|
|
||||||
|
|
||||||
void ds1315_device::device_start()
|
|
||||||
{
|
|
||||||
DEVICE_START_NAME( ds1315 )(this);
|
|
||||||
}
|
|
||||||
|
@ -18,28 +18,43 @@
|
|||||||
MACROS
|
MACROS
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
|
enum ds1315_mode_t
|
||||||
|
{
|
||||||
|
DS_SEEK_MATCHING,
|
||||||
|
DS_CALENDAR_IO
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class ds1315_device : public device_t
|
class ds1315_device : public device_t
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ds1315_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
ds1315_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||||
~ds1315_device() { global_free(m_token); }
|
~ds1315_device() {}
|
||||||
|
|
||||||
|
DECLARE_READ8_MEMBER(read_0);
|
||||||
|
DECLARE_READ8_MEMBER(read_1);
|
||||||
|
DECLARE_READ8_MEMBER(read_data);
|
||||||
|
DECLARE_WRITE8_MEMBER(write_data);
|
||||||
|
|
||||||
// access to legacy token
|
|
||||||
void *token() const { assert(m_token != NULL); return m_token; }
|
|
||||||
protected:
|
protected:
|
||||||
// device-level overrides
|
// device-level overrides
|
||||||
virtual void device_config_complete();
|
virtual void device_config_complete();
|
||||||
virtual void device_start();
|
virtual void device_start();
|
||||||
|
virtual void device_reset();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// internal state
|
// internal state
|
||||||
void *m_token;
|
|
||||||
|
void fill_raw_data();
|
||||||
|
void input_raw_data();
|
||||||
|
|
||||||
|
int m_count;
|
||||||
|
ds1315_mode_t m_mode;
|
||||||
|
UINT8 m_raw_data[8*8];
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const device_type DS1315;
|
extern const device_type DS1315;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
DEVICE CONFIGURATION MACROS
|
DEVICE CONFIGURATION MACROS
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
@ -48,13 +63,4 @@ extern const device_type DS1315;
|
|||||||
MCFG_DEVICE_ADD(_tag, DS1315, 0)
|
MCFG_DEVICE_ADD(_tag, DS1315, 0)
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
|
||||||
FUNCTION PROTOTYPES
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
DECLARE_READ8_DEVICE_HANDLER( ds1315_r_0 );
|
|
||||||
DECLARE_READ8_DEVICE_HANDLER( ds1315_r_1 );
|
|
||||||
DECLARE_READ8_DEVICE_HANDLER( ds1315_r_data );
|
|
||||||
DECLARE_WRITE8_DEVICE_HANDLER( ds1315_w_data );
|
|
||||||
|
|
||||||
#endif /* __DS1315_H__ */
|
#endif /* __DS1315_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user