• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ BCD2BIN函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中BCD2BIN函数的典型用法代码示例。如果您正苦于以下问题:C++ BCD2BIN函数的具体用法?C++ BCD2BIN怎么用?C++ BCD2BIN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了BCD2BIN函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: rtc_get_time_impl

static uint64_t
rtc_get_time_impl(struct rtc_interface *rtci, struct s3c2410_rtc *device)
{
    uint64_t unix_time;
    struct rtc_time tm;

    int reads = 0;
    tm.sec = 0;

    /* If BCDSEC is zero then we read during an update, reread. */
    while (tm.sec == 0 && reads <= 1) {
        tm.sec  = BCD2BIN(bcdsec_get_secdata());
        tm.min  = BCD2BIN(bcdmin_get_mindata());
        tm.hour = BCD2BIN(bcdhour_get_hourdata());
        tm.date = BCD2BIN(bcddate_get_datedata());
        tm.mon  = BCD2BIN(bcdmon_get_mondata());
        /* s3c410 rtc only has two digits for year, assumes 21st century. */
        tm.year = bcdyear_get_yeardata();

        reads++;
    }

    if (rtc_to_unix(&unix_time, &tm) != 0) {
        printf("%s: WARNING RTC returned invalid time value\n", __func__);
    }

    //printf("%s: time is: unix_time=%llu ... year=%d, mon=%d, date=%d, hour=%d, min=%d, sec=%d\n", __func__, unix_time, tm.year, tm.mon, tm.date, tm.hour, tm.min, tm.sec);


    return unix_time;
}
开发者ID:BreezeWu,项目名称:okl4_3.0,代码行数:31,代码来源:main.c


示例2: rtc_get_status

static inline int rtc_get_status(char *buf)
{
	char *p;
	unsigned int year;
	struct upd4990a_raw_data data;

	p = buf;

	upd4990a_get_time(&data, 0);

	/*
	 * There is no way to tell if the luser has the RTC set for local
	 * time or for Universal Standard Time (GMT). Probably local though.
	 */
	if ((year = BCD2BIN(data.year) + 1900) < 1995)
		year += 100;
	p += sprintf(p,
		     "rtc_time\t: %02d:%02d:%02d\n"
		     "rtc_date\t: %04d-%02d-%02d\n",
		     BCD2BIN(data.hour), BCD2BIN(data.min),
		     BCD2BIN(data.sec),
		     year, data.mon, BCD2BIN(data.mday));

	return  p - buf;
}
开发者ID:iPodLinux,项目名称:linux-2.6.7-ipod,代码行数:25,代码来源:upd4990a.c


示例3: get_year_day

uint16_t get_year_day(ds1307_time_t *tm) {
	uint16_t day = 0;
	int8_t i = BCD2BIN(tm->month);

	while (--i) {
		day += get_month_days(i, BCD2BIN(tm->year));
	}

	day += BCD2BIN(tm->dom);
	return day;
}
开发者ID:matko01,项目名称:avr_ArduinoProjects,代码行数:11,代码来源:sys_util.c


示例4: s35390a_reg2hr

static int s35390a_reg2hr(struct s35390a *s35390a, char reg)
{
	unsigned hour;

	if (s35390a->twentyfourhour)
		return BCD2BIN(reg & 0x3f);

	hour = BCD2BIN(reg & 0x3f);
	if (reg & 0x40)
		hour += 12;

	return hour;
}
开发者ID:mobilipia,项目名称:iods,代码行数:13,代码来源:rtc-s35390a.c


示例5: rs5c_reg2hr

static unsigned rs5c_reg2hr(struct rs5c372 *rs5c, unsigned reg)
{
	unsigned	hour;

	if (rs5c->time24)
		return BCD2BIN(reg & 0x3f);

	hour = BCD2BIN(reg & 0x1f);
	if (hour == 12)
		hour = 0;
	if (reg & 0x20)
		hour += 12;
	return hour;
}
开发者ID:ivucica,项目名称:linux,代码行数:14,代码来源:rtc-rs5c372.c


示例6: compute_dcf77_timestamp

// compute unix-timestamp from dcf77_ctx
static inline uint32_t
compute_dcf77_timestamp(void)
{
  clock_datetime_t dcfdate;
  dcfdate.sec = 0;
  dcfdate.min = BCD2BIN(dcf.time[2]);
  dcfdate.hour = BCD2BIN(dcf.time[3]);
  dcfdate.day = BCD2BIN(dcf.time[4]);
  dcfdate.month = BCD2BIN(dcf.time[6]);
  dcfdate.dow = dcf.time[5]; // nach ISO erster Tag Montag, nicht So!
  dcfdate.year = 100 + (BCD2BIN(dcf.time[7]));
  dcfdate.isdst = dcf.isdst;
  return clock_mktime(&dcfdate, 1);
}
开发者ID:1234tester,项目名称:ethersex,代码行数:15,代码来源:dcf77.c


示例7: RTCFUNC

int
RTCFUNC(get,ds3232)(struct tm *tm, int cent_reg)
{
    unsigned char   date[7];

    ds3232_i2c_read(DS3232_SEC, date, 7);

    tm->tm_sec  = BCD2BIN(date[DS3232_SEC] & 0x7f);
    tm->tm_min  = BCD2BIN(date[DS3232_MIN] & 0x7f);

	if ((date[DS3232_HOUR] & 0x40)) {
		/* the rtc is in 12 hour mode */ 
		int hour = BCD2BIN(date[DS3232_HOUR] & 0x1f);

		if ((date[DS3232_HOUR] & 0x20))  
			tm->tm_hour = (hour == 12) ? 12 : hour + 12; /* pm */
		else
			tm->tm_hour = (hour == 12) ? 0 : hour;  	 /* am */

	} else { 
		/* rejoice! the rtc is in 24 hour mode */ 
     	tm->tm_hour = BCD2BIN(date[DS3232_HOUR] & 0x3f);
	}

    tm->tm_mday = BCD2BIN(date[DS3232_DATE] & 0x3f);
    tm->tm_mon  = BCD2BIN(date[DS3232_MONTH] & 0x1f) - 1;
    tm->tm_year = BCD2BIN(date[DS3232_YEAR] & 0xff);

	if ((date[DS3232_MONTH] & 0x80))  
		tm->tm_year += 100;

    tm->tm_wday = BCD2BIN(date[DS3232_DAY] & 0x7) - 1;

    return(0);
}
开发者ID:nguyenvuhung,项目名称:SDP_QNX_BBB,代码行数:35,代码来源:clk_ds3232.c


示例8: max6902_get_datetime

static int max6902_get_datetime(struct device *dev, struct rtc_time *dt)
{
	unsigned char tmp;
	int century;
	int err;
	struct spi_device *spi = to_spi_device(dev);
	struct max6902 *chip = dev_get_drvdata(dev);
	struct spi_message message;
	struct spi_transfer xfer;
	int status;

	err = max6902_get_reg(dev, MAX6902_REG_CENTURY, &tmp);
	if (err)
		return err;

	/* build the message */
	spi_message_init(&message);
	memset(&xfer, 0, sizeof(xfer));
	xfer.len = 1 + 7;	/* Burst read command + 7 registers */
	xfer.tx_buf = chip->buf;
	xfer.rx_buf = chip->buf;
	chip->buf[0] = 0xbf;	/* Burst read */
	spi_message_add_tail(&xfer, &message);

	/* do the i/o */
	status = spi_sync(spi, &message);
	if (status == 0)
		status = message.status;
	else
		return status;

	/* The chip sends data in this order:
	 * Seconds, Minutes, Hours, Date, Month, Day, Year */
	dt->tm_sec	= BCD2BIN(chip->buf[1]);
	dt->tm_min	= BCD2BIN(chip->buf[2]);
	dt->tm_hour	= BCD2BIN(chip->buf[3]);
	dt->tm_mday	= BCD2BIN(chip->buf[4]);
	dt->tm_mon	= BCD2BIN(chip->buf[5]) - 1;
	dt->tm_wday	= BCD2BIN(chip->buf[6]);
	dt->tm_year = BCD2BIN(chip->buf[7]);

	century = BCD2BIN(tmp) * 100;

	dt->tm_year += century;
	dt->tm_year -= 1900;

#ifdef MAX6902_DEBUG
	printk("\n%s : Read RTC values\n",__FUNCTION__);
	printk("tm_hour: %i\n",dt->tm_hour);
	printk("tm_min : %i\n",dt->tm_min);
	printk("tm_sec : %i\n",dt->tm_sec);
	printk("tm_year: %i\n",dt->tm_year);
	printk("tm_mon : %i\n",dt->tm_mon);
	printk("tm_mday: %i\n",dt->tm_mday);
	printk("tm_wday: %i\n",dt->tm_wday);
#endif

	return 0;
}
开发者ID:xf739645524,项目名称:kernel-rhel5,代码行数:59,代码来源:rtc-max6902.c


示例9: sh_rtc_read_time

static int sh_rtc_read_time(struct device *dev, struct rtc_time *tm)
{
	struct platform_device *pdev = to_platform_device(dev);
	struct sh_rtc *rtc = platform_get_drvdata(pdev);
	unsigned int sec128, sec2, yr, yr100, cf_bit;

	do {
		unsigned int tmp;

		spin_lock_irq(&rtc->lock);

		tmp = readb(rtc->regbase + RCR1);
		tmp &= ~RCR1_CF; /* Clear CF-bit */
		tmp |= RCR1_CIE;
		writeb(tmp, rtc->regbase + RCR1);

		sec128 = readb(rtc->regbase + R64CNT);

		tm->tm_sec	= BCD2BIN(readb(rtc->regbase + RSECCNT));
		tm->tm_min	= BCD2BIN(readb(rtc->regbase + RMINCNT));
		tm->tm_hour	= BCD2BIN(readb(rtc->regbase + RHRCNT));
		tm->tm_wday	= BCD2BIN(readb(rtc->regbase + RWKCNT));
		tm->tm_mday	= BCD2BIN(readb(rtc->regbase + RDAYCNT));
		tm->tm_mon	= BCD2BIN(readb(rtc->regbase + RMONCNT)) - 1;

#if defined(CONFIG_CPU_SH4)
		yr  = readw(rtc->regbase + RYRCNT);
		yr100 = BCD2BIN(yr >> 8);
		yr &= 0xff;
#else
		yr  = readb(rtc->regbase + RYRCNT);
		yr100 = BCD2BIN((yr == 0x99) ? 0x19 : 0x20);
#endif

		tm->tm_year = (yr100 * 100 + BCD2BIN(yr)) - 1900;

		sec2 = readb(rtc->regbase + R64CNT);
		cf_bit = readb(rtc->regbase + RCR1) & RCR1_CF;

		spin_unlock_irq(&rtc->lock);
	} while (cf_bit != 0 || ((sec128 ^ sec2) & RTC_BIT_INVERTED) != 0);

#if RTC_BIT_INVERTED != 0
	if ((sec128 & RTC_BIT_INVERTED))
		tm->tm_sec--;
#endif

	dev_dbg(dev, "%s: tm is secs=%d, mins=%d, hours=%d, "
		"mday=%d, mon=%d, year=%d, wday=%d\n",
		__FUNCTION__,
		tm->tm_sec, tm->tm_min, tm->tm_hour,
		tm->tm_mday, tm->tm_mon + 1, tm->tm_year, tm->tm_wday);

	if (rtc_valid_tm(tm) < 0)
		dev_err(dev, "invalid date\n");

	return 0;
}
开发者ID:cilynx,项目名称:dd-wrt,代码行数:58,代码来源:rtc-sh.c


示例10: rs5c_read_alarm

static int rs5c_read_alarm(struct device *dev, struct rtc_wkalrm *t)
{
	struct i2c_client	*client = to_i2c_client(dev);
	struct rs5c372		*rs5c = i2c_get_clientdata(client);
	int			status;

	status = rs5c_get_regs(rs5c);
	if (status < 0)
		return status;

	/* report alarm time */
	t->time.tm_sec = 0;
	t->time.tm_min = BCD2BIN(rs5c->regs[RS5C_REG_ALARM_A_MIN] & 0x7f);
	t->time.tm_hour = rs5c_reg2hr(rs5c, rs5c->regs[RS5C_REG_ALARM_A_HOURS]);
	t->time.tm_mday = -1;
	t->time.tm_mon = -1;
	t->time.tm_year = -1;
	t->time.tm_wday = -1;
	t->time.tm_yday = -1;
	t->time.tm_isdst = -1;

	/* ... and status */
	t->enabled = !!(rs5c->regs[RS5C_REG_CTRL1] & RS5C_CTRL1_AALE);
	t->pending = !!(rs5c->regs[RS5C_REG_CTRL2] & RS5C_CTRL2_AAFG);

	return 0;
}
开发者ID:ivucica,项目名称:linux,代码行数:27,代码来源:rtc-rs5c372.c


示例11: at91_rtc_decodetime

/*
 * Decode time/date into rtc_time structure
 */
static void at91_rtc_decodetime(unsigned int timereg, unsigned int calreg,
				struct rtc_time *tm)
{
	unsigned int time, date;

	/* must read twice in case it changes */
	do {
		time = at91_sys_read(timereg);
		date = at91_sys_read(calreg);
	} while ((time != at91_sys_read(timereg)) ||
			(date != at91_sys_read(calreg)));

	tm->tm_sec  = BCD2BIN((time & AT91_RTC_SEC) >> 0);
	tm->tm_min  = BCD2BIN((time & AT91_RTC_MIN) >> 8);
	tm->tm_hour = BCD2BIN((time & AT91_RTC_HOUR) >> 16);

	/*
	 * The Calendar Alarm register does not have a field for
	 * the year - so these will return an invalid value.  When an
	 * alarm is set, at91_alarm_year wille store the current year.
	 */
	tm->tm_year  = BCD2BIN(date & AT91_RTC_CENT) * 100;	/* century */
	tm->tm_year += BCD2BIN((date & AT91_RTC_YEAR) >> 8);	/* year */

	tm->tm_wday = BCD2BIN((date & AT91_RTC_DAY) >> 21) - 1;	/* day of the week [0-6], Sunday=0 */
	tm->tm_mon  = BCD2BIN((date & AT91_RTC_MONTH) >> 16) - 1;
	tm->tm_mday = BCD2BIN((date & AT91_RTC_DATE) >> 24);
}
开发者ID:mobilipia,项目名称:iods,代码行数:31,代码来源:rtc-at91rm9200.c


示例12: rtc_get

/*
 * In the routines that deal directly with the x1205 hardware, we use
 * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch
 * Epoch is initialized as 2000. Time is set to UTC.
 */
void rtc_get(struct rtc_time *tm)
{
	u8 buf[8];

	i2c_read(CFG_I2C_RTC_ADDR, X1205_CCR_BASE, 2, buf, 8);

	debug("%s: raw read data - sec=%02x, min=%02x, hr=%02x, "
	      "mday=%02x, mon=%02x, year=%02x, wday=%02x, y2k=%02x\n",
	      __FUNCTION__,
	      buf[0], buf[1], buf[2], buf[3],
	      buf[4], buf[5], buf[6], buf[7]);

	tm->tm_sec = BCD2BIN(buf[CCR_SEC]);
	tm->tm_min = BCD2BIN(buf[CCR_MIN]);
	tm->tm_hour = BCD2BIN(buf[CCR_HOUR] & 0x3F); /* hr is 0-23 */
	tm->tm_mday = BCD2BIN(buf[CCR_MDAY]);
	tm->tm_mon = BCD2BIN(buf[CCR_MONTH]); /* mon is 0-11 */
	tm->tm_year = BCD2BIN(buf[CCR_YEAR])
		+ (BCD2BIN(buf[CCR_Y2K]) * 100);
	tm->tm_wday = buf[CCR_WDAY];

	debug("%s: tm is secs=%d, mins=%d, hours=%d, "
	      "mday=%d, mon=%d, year=%d, wday=%d\n",
	      __FUNCTION__,
	      tm->tm_sec, tm->tm_min, tm->tm_hour,
	      tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday);
}
开发者ID:CharlieWood,项目名称:uboot-imx,代码行数:32,代码来源:x1205.c


示例13: m48t37y_get_time

unsigned long m48t37y_get_time(void)
{
#ifdef CONFIG_MIPS64
	unsigned char *rtc_base = (unsigned char*)0xfffffffffc800000;
#else
	unsigned char* rtc_base = (unsigned char*)0xfc800000;
#endif
	unsigned int year, month, day, hour, min, sec;

	/* stop the update */
	rtc_base[0x7ff8] = 0x40;

	year = BCD2BIN(rtc_base[0x7fff]);
	year += BCD2BIN(rtc_base[0x7ff1]) * 100;

	month = BCD2BIN(rtc_base[0x7ffe]);

	day = BCD2BIN(rtc_base[0x7ffd]);

	hour = BCD2BIN(rtc_base[0x7ffb]);
	min = BCD2BIN(rtc_base[0x7ffa]);
	sec = BCD2BIN(rtc_base[0x7ff9]);

	/* start the update */
	rtc_base[0x7ff8] = 0x00;

	return mktime(year, month, day, hour, min, sec);
}
开发者ID:OpenHMR,项目名称:Open-HMR600,代码行数:28,代码来源:setup.c


示例14: RTCFUNC

int
RTCFUNC(get,m41t00)(struct tm *tm, int cent_reg)
{
    unsigned char   date[7];
    unsigned char   century;

    m41t00_i2c_read(M41T00_SEC, date, 7);

    tm->tm_sec  = BCD2BIN(date[M41T00_SEC] & ~M41T00_SEC_ST);
    tm->tm_min  = BCD2BIN(date[M41T00_MIN]);
    tm->tm_hour = BCD2BIN(date[M41T00_HOUR] & 
                          ~(M41T00_HOUR_CEB|M41T00_HOUR_CB));
    tm->tm_mday = BCD2BIN(date[M41T00_DATE]);
    tm->tm_mon  = BCD2BIN(date[M41T00_MONTH]) - 1;
    tm->tm_year = BCD2BIN(date[M41T00_YEAR]);
    tm->tm_wday = BCD2BIN(date[M41T00_DAY]) - 1;

    if (date[M41T00_HOUR] & M41T00_HOUR_CEB) {
        century = date[M41T00_HOUR] & M41T00_HOUR_CB;
        if (century) {
            if (tm->tm_year < 70) 
                tm->tm_year += 200;
        } else {
            tm->tm_year += 100;
        }
    } else {
        if(tm->tm_year < 70) 
            tm->tm_year += 100;
    }
    return(0);
}
开发者ID:nguyenvuhung,项目名称:SDP_QNX_BBB,代码行数:31,代码来源:clk_m41t00.c


示例15: ds1216_rtc_read_time

static int ds1216_rtc_read_time(struct device *dev, struct rtc_time *tm)
{
    struct platform_device *pdev = to_platform_device(dev);
    struct ds1216_priv *priv = platform_get_drvdata(pdev);
    struct ds1216_regs regs;

    ds1216_switch_ds_to_clock(priv->ioaddr);
    ds1216_read(priv->ioaddr, (u8 *)&regs);

    tm->tm_sec = BCD2BIN(regs.sec);
    tm->tm_min = BCD2BIN(regs.min);
    if (regs.hour & DS1216_HOUR_1224) {
        /* AM/PM mode */
        tm->tm_hour = BCD2BIN(regs.hour & 0x1f);
        if (regs.hour & DS1216_HOUR_AMPM)
            tm->tm_hour += 12;
    } else
        tm->tm_hour = BCD2BIN(regs.hour & 0x3f);
    tm->tm_wday = (regs.wday & 7) - 1;
    tm->tm_mday = BCD2BIN(regs.mday & 0x3f);
    tm->tm_mon = BCD2BIN(regs.month & 0x1f);
    tm->tm_year = BCD2BIN(regs.year);
    if (tm->tm_year < 70)
        tm->tm_year += 100;
    return 0;
}
开发者ID:274914765,项目名称:C,代码行数:26,代码来源:rtc-ds1216.c


示例16: get_swarm_time

static unsigned long __init get_swarm_time(void)
{
    unsigned int year, mon, day, hour, min, sec, y2k;

    sec = xicor_read(X1241REG_SC);
    min = xicor_read(X1241REG_MN);
    hour = xicor_read(X1241REG_HR);

    if (hour & X1241REG_HR_MIL) {
        hour &= 0x3f;
    } else {
        if (hour & 0x20)
            hour = (hour & 0xf) + 0x12;
    }

    sec = BCD2BIN(sec);
    min = BCD2BIN(min);
    hour = BCD2BIN(hour);

    day = xicor_read(X1241REG_DT);
    mon = xicor_read(X1241REG_MO);
    year = xicor_read(X1241REG_YR);
    y2k = xicor_read(X1241REG_Y2K);

    day = BCD2BIN(day);
    mon = BCD2BIN(mon);
    year = BCD2BIN(year);
    y2k = BCD2BIN(y2k);

    year += (y2k * 100);

    return mktime(year, mon, day, hour, min, sec);
}
开发者ID:xricson,项目名称:knoppix,代码行数:33,代码来源:time.c


示例17: s353xxa_rtc_read_time

static int s353xxa_rtc_read_time(struct device *dev, struct rtc_time *t)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct i2c_msg msgs[1];
	u8 buf[7];
	int ret;

	DEBUG_FUNC();

	set_i2c_msg(&msgs[0], client->addr | 0x2, I2C_M_RD, 7, buf);
	ret = i2c_transfer(client->adapter, msgs, 1);
	if (ret != 1)
		return -EIO;

	t->tm_year = BCD2BIN(REVERSE(buf[0]));
	t->tm_mon = BCD2BIN(REVERSE(buf[1]));
	t->tm_mday = BCD2BIN(REVERSE(buf[2]));
	t->tm_wday = BCD2BIN(REVERSE(buf[3]));
	t->tm_hour = BCD2BIN(REVERSE(buf[4]) & 0x3f);
	t->tm_min = BCD2BIN(REVERSE(buf[5]));
	t->tm_sec = BCD2BIN(REVERSE(buf[6]));

	t->tm_year += 100;
	t->tm_mon -= 1;

	DEBUG_INFO("READ: %d/%d/%d(%d) %d:%d:%d\n",
		   t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_wday,
		   t->tm_hour, t->tm_min, t->tm_sec);

	return 0;
}
开发者ID:miettal,项目名称:armadillo420_standard,代码行数:31,代码来源:rtc-s353xxa.c


示例18: s35392a_read_time

static int
s35392a_read_time(struct device* pDev, struct rtc_time* pTm)
{
	unsigned char rtc_reg[7];
	int ret;

	ret = s35392a_read_reg(S35392A_REALTIME_DATA1, rtc_reg, sizeof(rtc_reg));

	if (ret < 0)
	{
		return ret;
	}

	pTm->tm_sec = BCD2BIN(rtc_reg[6] & S35392A_SEC_MASK);
	pTm->tm_min = BCD2BIN(rtc_reg[5] & S35392A_MIN_MASK);
	pTm->tm_hour = BCD2BIN(rtc_reg[4] & S35392A_HOUR_MASK);
	pTm->tm_wday = BCD2BIN(rtc_reg[3] & S35392A_WDAY_MASK);
	pTm->tm_mday = BCD2BIN(rtc_reg[2] & S35392A_DAY_MASK);
	pTm->tm_mon = BCD2BIN(rtc_reg[1]  & S35392A_MON_MASK) - 1;		/* 0~11 for linux appl, 1~12 for rtc */
	pTm->tm_year = BCD2BIN(rtc_reg[0] & S35392A_YEAR_MASK) + 100;	/* 1900 for linux appl, 2000 for rtc */
	/* don't use tm_yday and tm_dst */

	MYTRACE(("%s : \n", __func__));
	MYTRACE(("YY:MM:DD:HH:MM:SS(%d:%2d:%2d:%2d:%2d:%2d)\n", pTm->tm_year, pTm->tm_mon, pTm->tm_mday, pTm->tm_hour, pTm->tm_min, pTm->tm_sec));

	return 0;
}
开发者ID:R0-Developers,项目名称:YP-R0_Kernel,代码行数:27,代码来源:rtc-s35392a.c


示例19: xicor_get_time

unsigned long xicor_get_time(void)
{
    unsigned int year, mon, day, hour, min, sec, y2k;
    unsigned long flags;

    spin_lock_irqsave(&rtc_lock, flags);
    sec = xicor_read(X1241REG_SC);
    min = xicor_read(X1241REG_MN);
    hour = xicor_read(X1241REG_HR);

    if (hour & X1241REG_HR_MIL) {
        hour &= 0x3f;
    } else {
        if (hour & 0x20)
            hour = (hour & 0xf) + 0x12;
    }

    day = xicor_read(X1241REG_DT);
    mon = xicor_read(X1241REG_MO);
    year = xicor_read(X1241REG_YR);
    y2k = xicor_read(X1241REG_Y2K);
    spin_unlock_irqrestore(&rtc_lock, flags);

    sec = BCD2BIN(sec);
    min = BCD2BIN(min);
    hour = BCD2BIN(hour);
    day = BCD2BIN(day);
    mon = BCD2BIN(mon);
    year = BCD2BIN(year);
    y2k = BCD2BIN(y2k);

    year += (y2k * 100);

    return mktime(year, mon, day, hour, min, sec);
}
开发者ID:274914765,项目名称:C,代码行数:35,代码来源:rtc_xicor1241.c


示例20: m48t37y_get_time

unsigned long m48t37y_get_time(void)
{
	unsigned int year, month, day, hour, min, sec;
	unsigned long flags;

	spin_lock_irqsave(&rtc_lock, flags);
	/* stop the update */
	rtc_base[0x7ff8] = 0x40;

	year = BCD2BIN(rtc_base[0x7fff]);
	year += BCD2BIN(rtc_base[0x7ff1]) * 100;

	month = BCD2BIN(rtc_base[0x7ffe]);

	day = BCD2BIN(rtc_base[0x7ffd]);

	hour = BCD2BIN(rtc_base[0x7ffb]);
	min = BCD2BIN(rtc_base[0x7ffa]);
	sec = BCD2BIN(rtc_base[0x7ff9]);

	/* start the update */
	rtc_base[0x7ff8] = 0x00;
	spin_unlock_irqrestore(&rtc_lock, flags);

	return mktime(year, month, day, hour, min, sec);
}
开发者ID:1x23,项目名称:unifi-gpl,代码行数:26,代码来源:setup.c



注:本文中的BCD2BIN函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ BCD_TO_BIN函数代码示例发布时间:2022-05-30
下一篇:
C++ BBox函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap