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

C++ BCD_TO_BIN函数代码示例

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

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



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

示例1: ds1307_convert_to_time

static void
ds1307_convert_to_time( struct rtc_time *dt, char *buf)
{
	dt->tm_sec = BCD_TO_BIN(buf[0]);
	dt->tm_min = BCD_TO_BIN(buf[1]);

	if ( TWELVE_HOUR_MODE(buf[2]) )
	{
		dt->tm_hour = HOURS_12(buf[2]);
		if (HOURS_AP(buf[2])) /* PM */
		{
			dt->tm_hour += 12;
		}
	}
	else /* 24-hour-mode */
	{
		dt->tm_hour = HOURS_24(buf[2]);
	}

	dt->tm_mday = BCD_TO_BIN(buf[4]);
	/* dt->tm_mon is zero-based */
	dt->tm_mon = BCD_TO_BIN(buf[5]) - 1;
	/* year is 1900 + dt->tm_year */
	dt->tm_year = BCD_TO_BIN(buf[6]) + 100;

	if( rtc_debug > 2)
	{
		printk("ds1307_get_datetime: year = %d\n", dt->tm_year);
		printk("ds1307_get_datetime: mon  = %d\n", dt->tm_mon);
		printk("ds1307_get_datetime: mday = %d\n", dt->tm_mday);
		printk("ds1307_get_datetime: hour = %d\n", dt->tm_hour);
		printk("ds1307_get_datetime: min  = %d\n", dt->tm_min);
		printk("ds1307_get_datetime: sec  = %d\n", dt->tm_sec);
	}
}
开发者ID:GunioRobot,项目名称:MI424WR_GEN2_Rev_E-F,代码行数:35,代码来源:ds1307.c


示例2: EntryPoints

/*****************************************************************************
 * EntryPoints: Reads the information about the entry points on the disc.
 *****************************************************************************/
static int EntryPoints( access_t *p_access )
{
    access_sys_t *p_sys = p_access->p_sys;
    uint8_t      sector[VCD_DATA_SIZE];

    entries_sect_t entries;
    int i_nb;

    /* Read the entry point sector */
    if( ioctl_ReadSectors( VLC_OBJECT(p_access), p_sys->vcddev,
        VCD_ENTRIES_SECTOR, sector, 1, VCD_TYPE ) < 0 )
    {
        msg_Err( p_access, "could not read entry points sector" );
        return VLC_EGENERIC;
    }
    memcpy( &entries, sector, CD_SECTOR_SIZE );

    i_nb = GetWBE( &entries.i_entries_nb );
    if( i_nb > 500 )
    {
        msg_Err( p_access, "invalid entry points number" );
        return VLC_EGENERIC;
    }

    if( strncmp( entries.psz_id, "ENTRYVCD", sizeof( entries.psz_id ) ) &&
        strncmp( entries.psz_id, "ENTRYSVD", sizeof( entries.psz_id ) ) )
    {
        msg_Err( p_access, "unrecognized entry points format" );
        return VLC_EGENERIC;
    }

    for( int i = 0; i < i_nb; i++ )
    {
        const int i_title = BCD_TO_BIN(entries.entry[i].i_track) - 2;
        const int i_sector =
            (MSF_TO_LBA2( BCD_TO_BIN( entries.entry[i].msf.minute ),
                          BCD_TO_BIN( entries.entry[i].msf.second ),
                          BCD_TO_BIN( entries.entry[i].msf.frame  ) ));
        seekpoint_t *s;

        if( i_title < 0 ) continue;   /* Should not occur */
        if( i_title >= p_sys->i_titles ) continue;

        msg_Dbg( p_access, "Entry[%d] title=%d sector=%d",
                 i, i_title, i_sector );

        s = vlc_seekpoint_New();
        s->i_byte_offset = (i_sector - p_sys->p_sectors[i_title+1]) *
            VCD_DATA_SIZE;

        TAB_APPEND( p_sys->title[i_title]->i_seekpoint,
                    p_sys->title[i_title]->seekpoint, s );
    }

    return VLC_SUCCESS;
}
开发者ID:Ackhuman,项目名称:vlc,代码行数:59,代码来源:vcd.c


示例3: getdate

void getdate( struct date *dateblk)
{
 unsigned long tmp;
 __asm__ __volatile__("int $0x40":"=a"(tmp):"0"(29)); 
 dateblk->da_year=2000+(tmp&0xff);
 dateblk->da_mon=(tmp>>8)&0xff;
 dateblk->da_day=(tmp>>16)&0xff;
 BCD_TO_BIN(dateblk->da_year);
 BCD_TO_BIN(dateblk->da_mon);
 BCD_TO_BIN(dateblk->da_day);
}
开发者ID:Misha-Mainenko,项目名称:kolibrios-llvm,代码行数:11,代码来源:getdate.c


示例4: _dos_getdate

void _dos_getdate(struct _dosdate_t *date)
{
 unsigned long tmp;
 __asm__ __volatile__("int $0x40":"=a"(tmp):"0"(29)); 
 date->year=2000+(tmp&0xff);
 date->month=(tmp>>8)&0xff;
 date->day= (tmp>>16)&0xff;
 date->dayofweek=0; /* xxx - how to do it correctly ? */
 BCD_TO_BIN(date->year);
 BCD_TO_BIN(date->month);
 BCD_TO_BIN(date->day);
}
开发者ID:Misha-Mainenko,项目名称:kolibrios-llvm,代码行数:12,代码来源:d_getdat.c


示例5: GetCmosTime

//---------------------------------------------------------------------------------------------------------------------------
//
// 获得 CMOS 时间
//
//---------------------------------------------------------------------------------------------------------------------------
void GetCmosTime(CmosTime* t)
{
	if (t) {
		t->sec =   ReadCmos(0);
		t->min =  ReadCmos(2);
		t->hour=  ReadCmos(4);
	}
	BCD_TO_BIN(t->sec);
	BCD_TO_BIN(t->min);
	BCD_TO_BIN(t->hour);

}
开发者ID:huashengshuita,项目名称:HITCS-30--FAT32-For-Linux0.11,代码行数:17,代码来源:Timer.c


示例6: GetCmosDate

//-----------------------------------------------------------------------------------------------------------------------------
//
//获得 CMOS 日期
//
//-----------------------------------------------------------------------------------------------------------------------------
void GetCmosDate(CmosDate* d)
{
	if (d) {
		d->dayofweek =ReadCmos(6);
		d->day =ReadCmos(7);
		d->month =ReadCmos(8);
		d->year = ReadCmos(9);
	}
	BCD_TO_BIN(d->day);
	BCD_TO_BIN(d->month);
	BCD_TO_BIN(d->year);
	d->year+=2000;

}
开发者ID:huashengshuita,项目名称:HITCS-30--FAT32-For-Linux0.11,代码行数:19,代码来源:Timer.c


示例7: set_rtc_mmss

/*
 * In order to set the CMOS clock precisely, set_rtc_mmss has to be called 500
 * ms after the second nowtime has started, because when nowtime is written
 * into the registers of the CMOS clock, it will jump to the next second
 * precisely 500 ms later.  Check the Motorola MC146818A or Dallas DS12887 data
 * sheet for details.
 *
 * BUG: This routine does not handle hour overflow properly; it just
 *      sets the minutes. Usually you'll only notice that after reboot!
 */
static int set_rtc_mmss(unsigned long nowtime)
{
    unsigned char save_control, save_freq_select;
    int retval = 0;
    int real_seconds, real_minutes, cmos_minutes;

    /* gets recalled with irq locally disabled */
    spin_lock(&rtc_lock);
    save_control = CMOS_READ(RTC_CONTROL); /* tell the clock it's being
                        * set */
    CMOS_WRITE(save_control | RTC_SET, RTC_CONTROL);

    save_freq_select = CMOS_READ(RTC_FREQ_SELECT); /* stop and reset
                            * prescaler */
    CMOS_WRITE(save_freq_select | RTC_DIV_RESET2, RTC_FREQ_SELECT);

    cmos_minutes = CMOS_READ(RTC_MINUTES);
    if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
        BCD_TO_BIN(cmos_minutes);

    /*
     * since we're only adjusting minutes and seconds,
     * don't interfere with hour overflow. This avoids
     * messing with unknown time zones but requires your
     * RTC not to be off by more than 15 minutes
     */
    real_seconds = nowtime % 60;
    real_minutes = nowtime / 60;
    if (((abs(real_minutes - cmos_minutes) + 15) / 30) & 1)
        /* correct for half hour time zone */
        real_minutes += 30;
    real_minutes %= 60;

    if (abs(real_minutes - cmos_minutes) < 30) {
        if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
            BIN_TO_BCD(real_seconds);
            BIN_TO_BCD(real_minutes);
        }
        CMOS_WRITE(real_seconds, RTC_SECONDS);
        CMOS_WRITE(real_minutes, RTC_MINUTES);
    } else {
        printk(KERN_WARNING
               "set_rtc_mmss: can't update from %d to %d\n",
               cmos_minutes, real_minutes);
        retval = -1;
    }

    /* The following flags have to be released exactly in this order,
     * otherwise the DS12887 (popular MC146818A clone with integrated
     * battery and quartz) will not reset the oscillator and will not
     * update precisely 500 ms later. You won't find this mentioned in
     * the Dallas Semiconductor data sheets, but who believes data
     * sheets anyway ...                           -- Markus Kuhn
     */
    CMOS_WRITE(save_control, RTC_CONTROL);
    CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT);
    spin_unlock(&rtc_lock);

    return retval;
}
开发者ID:274914765,项目名称:C,代码行数:70,代码来源:rtc.c


示例8: __initfunc

__initfunc(int rtc_init(void))
{
	unsigned long flags;
#ifdef __alpha__
	unsigned int year, ctrl;
	unsigned long uip_watchdog;
	char *guess = NULL;
#endif
	printk(KERN_INFO "Real Time Clock Driver v%s\n", RTC_VERSION);
	if(request_irq(RTC_IRQ, rtc_interrupt, SA_INTERRUPT, "rtc", NULL))
	{
		/* Yeah right, seeing as irq 8 doesn't even hit the bus. */
		printk(KERN_ERR "rtc: IRQ %d is not free.\n", RTC_IRQ);
		return -EIO;
	}
	misc_register(&rtc_dev);
	/* Check region? Naaah! Just snarf it up. */
	request_region(RTC_PORT(0), RTC_IO_EXTENT, "rtc");
#ifdef __alpha__
	rtc_freq = HZ;
	
	/* Each operating system on an Alpha uses its own epoch.
	   Let's try to guess which one we are using now. */
	
	uip_watchdog = jiffies;
	if (rtc_is_updating() != 0)
		while (jiffies - uip_watchdog < 2*HZ/100)
			barrier();
	
	save_flags(flags);
	cli();
	year = CMOS_READ(RTC_YEAR);
	ctrl = CMOS_READ(RTC_CONTROL);
	restore_flags(flags);
	
	if (!(ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
		BCD_TO_BIN(year);       /* This should never happen... */
	
	if (year > 10 && year < 44) {
		epoch = 1980;
		guess = "ARC console";
	} else if (year < 96) {
		epoch = 1952;
		guess = "Digital UNIX";
	}
	if (guess)
		printk("rtc: %s epoch (%lu) detected\n", guess, epoch);
#endif
	init_timer(&rtc_irq_timer);
	rtc_irq_timer.function = rtc_dropped_irq;
	rtc_wait = NULL;
	save_flags(flags);
	cli();
	/* Initialize periodic freq. to CMOS reset default, which is 1024Hz */
	CMOS_WRITE(((CMOS_READ(RTC_FREQ_SELECT) & 0xF0) | 0x06), RTC_FREQ_SELECT);
	restore_flags(flags);
	rtc_freq = 1024;
	return 0;
}
开发者ID:chinnyannieb,项目名称:empeg-hijack,代码行数:59,代码来源:rtc.c


示例9: getDate

/*==========================================================================
 FUNCTION:DS3231 driver
 PURPOSE:
 ---------------------------------------------------------------------------*/
bool Crtc::getDate(u16* year, u08* mon, u08* day, u08* hour, u08* min) {
	u08 buf[0x12];
	// send address
	buf[0] = 0x00;
	i2c->masterSend(rtc_id, 1, buf);
	// get the data
	i2c->masterReceive(rtc_id, 7, buf);

	//datetime.sec = BCD_TO_BIN (buf[0] & 0x7F);
	*min = BCD_TO_BIN (buf[1] & 0x7F);
	*hour = BCD_TO_BIN (buf[2] & 0x3F);
	//*wday = (buf[3]) & 0x7; //1--7
	*day = BCD_TO_BIN (buf[4] & 0x3F); //01--31
	*mon = BCD_TO_BIN (buf[5] & 0x1F);
	*year = BCD_TO_BIN (buf[6]) + 2000; /* byte*/
	return true;
}
开发者ID:woutercloete,项目名称:cableguard,代码行数:21,代码来源:MCP7940x.cpp


示例10: evm_read_time

static int evm_read_time(struct device *dev, struct rtc_time *tm)
{
	char rtcdata [9];

	rtcdata[0] = 2;
	rtcdata[1] = 1;
	davinci_i2c_write(2, rtcdata, 0x23);

	msleep(1);
	davinci_i2c_read(9, rtcdata, 0x23);
	msleep(1);

	/* FIXME the RTC reports 12-hour time, without an AM/PM indicator,
	 * but Linux requires that we report 24 hour time...
	 */

	tm->tm_year = BCD_TO_BIN(rtcdata[3]) * 100
			+ BCD_TO_BIN(rtcdata[2])
			- 1900;
	tm->tm_mon = BCD_TO_BIN(rtcdata[4]);
	tm->tm_mday = BCD_TO_BIN(rtcdata[5]);
	tm->tm_hour = BCD_TO_BIN(rtcdata[6]);
	tm->tm_min = BCD_TO_BIN(rtcdata[7]);
	tm->tm_sec = BCD_TO_BIN(rtcdata[8]);

	return 0;
}
开发者ID:mrtos,项目名称:Logitech-Revue,代码行数:27,代码来源:rtc-davinci-evm.c


示例11: 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;
	}

	BCD_TO_BIN(sec);
	BCD_TO_BIN(min);
	BCD_TO_BIN(hour);

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

	year += (y2k * 100);

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


示例12: pcf8563_read

INT8S pcf8563_read(TIME* ptime)
{
	INT8U time_ram[10];
	INT8U sub_addr, mode, year;

	if(NULL == ptime){
		return -1;
	}

	mode = 1;
	sub_addr = 0x02;
	
	if(IRcvStr(PCF8563_I2C_PORT, 0xA2, sub_addr, mode, time_ram, 7) == false){
		return 	-1;
	}
	
	ptime->second = BCD_TO_BIN(time_ram[0] & 0x7F);
	ptime->minute = BCD_TO_BIN(time_ram[1] & 0x7F);
	ptime->hour   = BCD_TO_BIN(time_ram[2] & 0x3F);
	ptime->day    = BCD_TO_BIN(time_ram[3] & 0x3F);
	ptime->week   = BCD_TO_BIN(time_ram[4] & 0x07);
	ptime->month  = BCD_TO_BIN(time_ram[5] & 0x1F);
	
	// йю╪меп╤о
	if(time_ram[5]&(0x80)){
		ptime->year = 1900;
	}else{
		ptime->year = 2000;
	}
	year = BCD_TO_BIN(time_ram[6]);
	ptime->year += year; 

	return 0;
}
开发者ID:postgetme,项目名称:crco,代码行数:34,代码来源:pcf8563.c


示例13: pcf8583_get_datetime

static int
pcf8583_get_datetime(struct i2c_client *client, struct rtc_tm *dt)
{
	unsigned char buf[8], addr[1] = { 1 };
	struct i2c_msg msgs[2] = {
		{ client->addr, 0,        1, addr },
		{ client->addr, I2C_M_RD, 6, buf  }
	};
	int ret = -EIO;

	memset(buf, 0, sizeof(buf));

	ret = i2c_transfer(client->adapter, msgs, 2);
	if (ret == 2) {
		dt->year_off = buf[4] >> 6;
		dt->wday     = buf[5] >> 5;

		buf[4] &= 0x3f;
		buf[5] &= 0x1f;

		dt->cs       = BCD_TO_BIN(buf[0]);
		dt->secs     = BCD_TO_BIN(buf[1]);
		dt->mins     = BCD_TO_BIN(buf[2]);
		dt->hours    = BCD_TO_BIN(buf[3]);
		dt->mday     = BCD_TO_BIN(buf[4]);
		dt->mon      = BCD_TO_BIN(buf[5]);

		ret = 0;
	}
开发者ID:sarnobat,项目名称:knoppix,代码行数:29,代码来源:pcf8583.c


示例14: time_init

static void time_init(void)
{
	struct mktime time;
	int i;

	for (i = 0 ; i < 1000000 ; i++)
		if (!(CMOS_READ(10) & 0x80))
			break;
	do {
		time.sec = CMOS_READ(0);
		time.min = CMOS_READ(2);
		time.hour = CMOS_READ(4);
		time.day = CMOS_READ(7);
		time.mon = CMOS_READ(8);
		time.year = CMOS_READ(9);
	} while (time.sec != CMOS_READ(0));
	BCD_TO_BIN(time.sec);
	BCD_TO_BIN(time.min);
	BCD_TO_BIN(time.hour);
	BCD_TO_BIN(time.day);
	BCD_TO_BIN(time.mon);
	BCD_TO_BIN(time.year);
	time.mon--;
	startup_time = kernel_mktime(&time);
}
开发者ID:LambdaCalculus379,项目名称:SLS-1.02,代码行数:25,代码来源:main.c


示例15: maple_get_rtc_time

void maple_get_rtc_time(struct rtc_time *tm)
{
	do {
		tm->tm_sec = maple_clock_read(RTC_SECONDS);
		tm->tm_min = maple_clock_read(RTC_MINUTES);
		tm->tm_hour = maple_clock_read(RTC_HOURS);
		tm->tm_mday = maple_clock_read(RTC_DAY_OF_MONTH);
		tm->tm_mon = maple_clock_read(RTC_MONTH);
		tm->tm_year = maple_clock_read(RTC_YEAR);
	} while (tm->tm_sec != maple_clock_read(RTC_SECONDS));

	if (!(maple_clock_read(RTC_CONTROL) & RTC_DM_BINARY)
	    || RTC_ALWAYS_BCD) {
		BCD_TO_BIN(tm->tm_sec);
		BCD_TO_BIN(tm->tm_min);
		BCD_TO_BIN(tm->tm_hour);
		BCD_TO_BIN(tm->tm_mday);
		BCD_TO_BIN(tm->tm_mon);
		BCD_TO_BIN(tm->tm_year);
	  }
	if ((tm->tm_year + 1900) < 1970)
		tm->tm_year += 100;

	GregorianDay(tm);
}
开发者ID:BackupTheBerlios,项目名称:arp2-svn,代码行数:25,代码来源:time.c


示例16: get_rtc_time

void
get_rtc_time(struct rtc_time *rtc_tm) 
{
	unsigned long flags;

	local_irq_save(flags);

	rtc_tm->tm_sec = CMOS_READ(RTC_SECONDS);
	rtc_tm->tm_min = CMOS_READ(RTC_MINUTES);
	rtc_tm->tm_hour = CMOS_READ(RTC_HOURS);
	rtc_tm->tm_mday = CMOS_READ(RTC_DAY_OF_MONTH);
	rtc_tm->tm_mon = CMOS_READ(RTC_MONTH);
	rtc_tm->tm_year = CMOS_READ(RTC_YEAR);

	local_irq_restore(flags);
	
	BCD_TO_BIN(rtc_tm->tm_sec);
	BCD_TO_BIN(rtc_tm->tm_min);
	BCD_TO_BIN(rtc_tm->tm_hour);
	BCD_TO_BIN(rtc_tm->tm_mday);
	BCD_TO_BIN(rtc_tm->tm_mon);
	BCD_TO_BIN(rtc_tm->tm_year);

	/*
	 * Account for differences between how the RTC uses the values
	 * and how they are defined in a struct rtc_time;
	 */

	if (rtc_tm->tm_year <= 69)
		rtc_tm->tm_year += 100;

	rtc_tm->tm_mon--;
}
开发者ID:ManiacTwister,项目名称:linux-hnd,代码行数:33,代码来源:ds1302.c


示例17: get_rtc_time

void
get_rtc_time(struct rtc_time *tm)
{
	tm->tm_sec = rtc_read(RTC_SECONDS);
	tm->tm_min = rtc_read(RTC_MINUTES);
	tm->tm_hour = rtc_read(RTC_HOURS);
	tm->tm_mday = rtc_read(RTC_DAY_OF_MONTH);
	tm->tm_mon = rtc_read(RTC_MONTH);
	tm->tm_year = rtc_read(RTC_YEAR);

	if (tm->tm_sec & 0x80)
		printk(KERN_WARNING "%s: RTC Low Voltage - date/time is not reliable!\n", PCF8563_NAME);

	tm->tm_year = BCD_TO_BIN(tm->tm_year) + ((tm->tm_mon & 0x80) ? 100 : 0);
	tm->tm_sec &= 0x7f;
	tm->tm_min &= 0x7f;
	tm->tm_hour &= 0x3f;
	tm->tm_mday &= 0x3f;
	tm->tm_mon &= 0x1f;

	BCD_TO_BIN(tm->tm_sec);
	BCD_TO_BIN(tm->tm_min);
	BCD_TO_BIN(tm->tm_hour);
	BCD_TO_BIN(tm->tm_mday);
	BCD_TO_BIN(tm->tm_mon);
	tm->tm_mon--; /* Month is 1..12 in RTC but 0..11 in linux */
}
开发者ID:12019,项目名称:hg556a_source,代码行数:27,代码来源:pcf8563.c


示例18: get_m48t35_time

static __init unsigned long get_m48t35_time(void)
{
	unsigned int year, month, date, hour, min, sec;
	struct m48t35_rtc *rtc;
	nasid_t nid;

	nid = get_nasid();
	rtc = (struct m48t35_rtc *)(KL_CONFIG_CH_CONS_INFO(nid)->memory_base +
							IOC3_BYTEBUS_DEV0);

	spin_lock(&rtc_lock);
	rtc->control |= M48T35_RTC_READ;
	sec = rtc->sec;
	min = rtc->min;
	hour = rtc->hour;
	date = rtc->date;
	month = rtc->month;
	year = rtc->year;
	rtc->control &= ~M48T35_RTC_READ;
	spin_unlock(&rtc_lock);

	BCD_TO_BIN(sec);
	BCD_TO_BIN(min);
	BCD_TO_BIN(hour);
	BCD_TO_BIN(date);
	BCD_TO_BIN(month);
	BCD_TO_BIN(year);

	year += 1970;

	return mktime(year, month, date, hour, min, sec);
}
开发者ID:Picture-Elements,项目名称:linux-2.4-peijse,代码行数:32,代码来源:ip27-timer.c


示例19: get_rtc_time

void
get_rtc_time(struct rtc_time *tm)
{
	tm->tm_sec  = rtc_read(RTC_SECONDS);
	tm->tm_min  = rtc_read(RTC_MINUTES);
	tm->tm_hour = rtc_read(RTC_HOURS);
	tm->tm_mday = rtc_read(RTC_DAY_OF_MONTH);
	tm->tm_wday = rtc_read(RTC_WEEKDAY);
	tm->tm_mon  = rtc_read(RTC_MONTH);
	tm->tm_year = rtc_read(RTC_YEAR);

	if (tm->tm_sec & 0x80)
		printk(KERN_WARNING "%s: RTC Voltage Low - reliable date/time "
		       "information is no longer guaranteed!\n", PCF8563_NAME);

	tm->tm_year  = BCD_TO_BIN(tm->tm_year) + ((tm->tm_mon & 0x80) ? 100 : 0);
	tm->tm_sec  &= 0x7F;
	tm->tm_min  &= 0x7F;
	tm->tm_hour &= 0x3F;
	tm->tm_mday &= 0x3F;
	tm->tm_wday &= 0x07; /* Not coded in BCD. */
	tm->tm_mon  &= 0x1F;

	BCD_TO_BIN(tm->tm_sec);
	BCD_TO_BIN(tm->tm_min);
	BCD_TO_BIN(tm->tm_hour);
	BCD_TO_BIN(tm->tm_mday);
	BCD_TO_BIN(tm->tm_mon);
	tm->tm_mon--; /* Month is 1..12 in RTC but 0..11 in linux */
}
开发者ID:Broadcom,项目名称:stblinux-2.6.18,代码行数:30,代码来源:pcf8563.c


示例20: GetBootTime

uint32 GetBootTime (void)
{
    uint32 i;
    struct Tm tm;

    for (i=0; i <10000000; i++)
        if ((CMOS_READ (CMOS_CTRL_REG_A) & RTC_UIP) == 0)
            break;

    tm.sec 	= CMOS_READ (CMOS_SECONDS);
    tm.min 	= CMOS_READ (CMOS_MINUTES);
    tm.hour	= CMOS_READ (CMOS_HOURS);
    tm.mday = CMOS_READ (CMOS_DATE_OF_MONTH);
    tm.mon 	= CMOS_READ (CMOS_MONTH);
    tm.year	= CMOS_READ (CMOS_YEAR);


    if (!(CMOS_READ (CMOS_CTRL_REG_B) & RTC_DM_BINARY))
    {
        BCD_TO_BIN (tm.sec);
        BCD_TO_BIN (tm.min);
        BCD_TO_BIN (tm.hour);
        BCD_TO_BIN (tm.mday);
        BCD_TO_BIN (tm.mon);
        BCD_TO_BIN (tm.year);
    }
    if ((tm.year += 1900) < 1970)
        tm.year += 100;

    tm.year -= 1900;
    tm.mon -=1;

    return MakeTime(&tm);
}
开发者ID:cod5,项目名称:kielder,代码行数:34,代码来源:boottime.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ BCM_DEBUG_PRINT函数代码示例发布时间:2022-05-30
下一篇:
C++ BCD2BIN函数代码示例发布时间: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