From b5c8272ad8f172377eb64bc0fb91a5e9753c43b2 Mon Sep 17 00:00:00 2001 From: Fabio Priuli Date: Mon, 1 Jun 2009 10:39:47 +0000 Subject: [PATCH] Converted DS1302 to use devtemplate --- src/emu/machine/ds1302.c | 46 ++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 30 deletions(-) diff --git a/src/emu/machine/ds1302.c b/src/emu/machine/ds1302.c index 08c624469b8..6542ec34634 100644 --- a/src/emu/machine/ds1302.c +++ b/src/emu/machine/ds1302.c @@ -28,8 +28,8 @@ TYPE DEFINITIONS ***************************************************************************/ -typedef struct _ds1302_t ds1302_t; -struct _ds1302_t +typedef struct _ds1302_state ds1302_state; +struct _ds1302_state { UINT32 shift_in; @@ -44,12 +44,12 @@ struct _ds1302_t 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->token != NULL); assert(device->type == DS1302); - return (ds1302_t *)device->token; + return (ds1302_state *)device->token; } INLINE UINT8 convert_to_bcd(int val) @@ -68,7 +68,7 @@ INLINE UINT8 convert_to_bcd(int val) WRITE8_DEVICE_HANDLER( ds1302_dat_w ) { - ds1302_t *ds1302 = get_safe_token(device); + ds1302_state *ds1302 = get_safe_token(device); if (data) ds1302->shift_in |= (1 << ds1302->icount); @@ -83,7 +83,7 @@ WRITE8_DEVICE_HANDLER( ds1302_dat_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) { @@ -178,7 +178,7 @@ WRITE8_DEVICE_HANDLER( ds1302_clk_w ) 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; } @@ -189,7 +189,7 @@ READ8_DEVICE_HANDLER( ds1302_read ) static DEVICE_START( ds1302 ) { - ds1302_t *ds1302 = get_safe_token(device); + ds1302_state *ds1302 = get_safe_token(device); /* register for state saving */ state_save_register_global(device->machine, ds1302->shift_in); @@ -206,7 +206,7 @@ static DEVICE_START( 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_out = 0; @@ -219,25 +219,11 @@ static DEVICE_RESET( ds1302 ) DEVICE_GET_INFO( ds1302 ) -------------------------------------------------*/ -DEVICE_GET_INFO( ds1302 ) -{ - 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; +static const char *DEVTEMPLATE_SOURCE = __FILE__; - /* --- the following bits of info are returned as pointers to data or functions --- */ - case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(ds1302); break; - case DEVINFO_FCT_STOP: /* Nothing */ break; - case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(ds1302); break; - - /* --- the following bits of info are returned as NULL-terminated strings --- */ - 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; - } -} +#define DEVTEMPLATE_ID(p,s) p##ds1302##s +#define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_RESET +#define DEVTEMPLATE_NAME "Dallas DS1302 RTC" +#define DEVTEMPLATE_FAMILY "Dallas DS1302 RTC" +#define DEVTEMPLATE_CLASS DEVICE_CLASS_PERIPHERAL +#include "devtempl.h"