mirror of
https://github.com/holub/mame
synced 2025-07-04 09:28:51 +03:00
Converted DS1302 to use devtemplate
This commit is contained in:
parent
37a38a958f
commit
b5c8272ad8
@ -28,8 +28,8 @@
|
|||||||
TYPE DEFINITIONS
|
TYPE DEFINITIONS
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
typedef struct _ds1302_t ds1302_t;
|
typedef struct _ds1302_state ds1302_state;
|
||||||
struct _ds1302_t
|
struct _ds1302_state
|
||||||
{
|
{
|
||||||
|
|
||||||
UINT32 shift_in;
|
UINT32 shift_in;
|
||||||
@ -44,12 +44,12 @@ struct _ds1302_t
|
|||||||
INLINE FUNCTIONS
|
INLINE FUNCTIONS
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
INLINE ds1302_t *get_safe_token(const device_config *device)
|
INLINE ds1302_state *get_safe_token(const device_config *device)
|
||||||
{
|
{
|
||||||
assert(device != NULL);
|
assert(device != NULL);
|
||||||
assert(device->token != NULL);
|
assert(device->token != NULL);
|
||||||
assert(device->type == DS1302);
|
assert(device->type == DS1302);
|
||||||
return (ds1302_t *)device->token;
|
return (ds1302_state *)device->token;
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE UINT8 convert_to_bcd(int val)
|
INLINE UINT8 convert_to_bcd(int val)
|
||||||
@ -68,7 +68,7 @@ INLINE UINT8 convert_to_bcd(int val)
|
|||||||
|
|
||||||
WRITE8_DEVICE_HANDLER( ds1302_dat_w )
|
WRITE8_DEVICE_HANDLER( ds1302_dat_w )
|
||||||
{
|
{
|
||||||
ds1302_t *ds1302 = get_safe_token(device);
|
ds1302_state *ds1302 = get_safe_token(device);
|
||||||
|
|
||||||
if (data)
|
if (data)
|
||||||
ds1302->shift_in |= (1 << ds1302->icount);
|
ds1302->shift_in |= (1 << ds1302->icount);
|
||||||
@ -83,7 +83,7 @@ WRITE8_DEVICE_HANDLER( ds1302_dat_w )
|
|||||||
|
|
||||||
WRITE8_DEVICE_HANDLER( ds1302_clk_w )
|
WRITE8_DEVICE_HANDLER( ds1302_clk_w )
|
||||||
{
|
{
|
||||||
ds1302_t *ds1302 = get_safe_token(device);
|
ds1302_state *ds1302 = get_safe_token(device);
|
||||||
|
|
||||||
if (data != ds1302->last_clk)
|
if (data != ds1302->last_clk)
|
||||||
{
|
{
|
||||||
@ -178,7 +178,7 @@ WRITE8_DEVICE_HANDLER( ds1302_clk_w )
|
|||||||
|
|
||||||
READ8_DEVICE_HANDLER( ds1302_read )
|
READ8_DEVICE_HANDLER( ds1302_read )
|
||||||
{
|
{
|
||||||
ds1302_t *ds1302 = get_safe_token(device);
|
ds1302_state *ds1302 = get_safe_token(device);
|
||||||
return (ds1302->shift_out & (1 << (ds1302->icount - 9))) ? 1 : 0;
|
return (ds1302->shift_out & (1 << (ds1302->icount - 9))) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +189,7 @@ READ8_DEVICE_HANDLER( ds1302_read )
|
|||||||
|
|
||||||
static DEVICE_START( ds1302 )
|
static DEVICE_START( ds1302 )
|
||||||
{
|
{
|
||||||
ds1302_t *ds1302 = get_safe_token(device);
|
ds1302_state *ds1302 = get_safe_token(device);
|
||||||
|
|
||||||
/* register for state saving */
|
/* register for state saving */
|
||||||
state_save_register_global(device->machine, ds1302->shift_in);
|
state_save_register_global(device->machine, ds1302->shift_in);
|
||||||
@ -206,7 +206,7 @@ static DEVICE_START( ds1302 )
|
|||||||
|
|
||||||
static DEVICE_RESET( ds1302 )
|
static DEVICE_RESET( ds1302 )
|
||||||
{
|
{
|
||||||
ds1302_t *ds1302 = get_safe_token(device);
|
ds1302_state *ds1302 = get_safe_token(device);
|
||||||
|
|
||||||
ds1302->shift_in = 0;
|
ds1302->shift_in = 0;
|
||||||
ds1302->shift_out = 0;
|
ds1302->shift_out = 0;
|
||||||
@ -219,25 +219,11 @@ static DEVICE_RESET( ds1302 )
|
|||||||
DEVICE_GET_INFO( ds1302 )
|
DEVICE_GET_INFO( ds1302 )
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
DEVICE_GET_INFO( ds1302 )
|
static const char *DEVTEMPLATE_SOURCE = __FILE__;
|
||||||
{
|
|
||||||
switch (state)
|
|
||||||
{
|
|
||||||
/* --- the following bits of info are returned as 64-bit signed integers --- */
|
|
||||||
case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(ds1302_t); break;
|
|
||||||
case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break;
|
|
||||||
case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break;
|
|
||||||
|
|
||||||
/* --- the following bits of info are returned as pointers to data or functions --- */
|
#define DEVTEMPLATE_ID(p,s) p##ds1302##s
|
||||||
case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(ds1302); break;
|
#define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_RESET
|
||||||
case DEVINFO_FCT_STOP: /* Nothing */ break;
|
#define DEVTEMPLATE_NAME "Dallas DS1302 RTC"
|
||||||
case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(ds1302); break;
|
#define DEVTEMPLATE_FAMILY "Dallas DS1302 RTC"
|
||||||
|
#define DEVTEMPLATE_CLASS DEVICE_CLASS_PERIPHERAL
|
||||||
/* --- the following bits of info are returned as NULL-terminated strings --- */
|
#include "devtempl.h"
|
||||||
case DEVINFO_STR_NAME: strcpy(info->s, "Dallas DS1302 RTC"); break;
|
|
||||||
case DEVINFO_STR_FAMILY: strcpy(info->s, "Dallas DS1302 RTC"); break;
|
|
||||||
case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break;
|
|
||||||
case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
|
|
||||||
case DEVINFO_STR_CREDITS: /* Nothing */ break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user