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

C++ rtc_tm_to_time函数代码示例

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

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



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

示例1: set_wakealarm

static int set_wakealarm(void)
{
	int retval = 0;
	unsigned long now, alarm;
	struct rtc_wkalrm alm;
	struct rtc_device *rtc;

	rtc = rtc_class_open(CONFIG_WAKEALARM_RTC);
	if (!rtc) {
		return -1;
	}

	/* Only request alarms that trigger in the future.  Disable them
	 * by writing another time, e.g. 0 meaning Jan 1 1970 UTC.
	 */
	retval = rtc_read_time(rtc, &alm.time);
	if (retval < 0)
		goto close_rtc;
	rtc_tm_to_time(&alm.time, &now);

	alarm = now + sleep_time;
	
	if (alarm > now) {
		/* Avoid accidentally clobbering active alarms; we can't
		 * entirely prevent that here, without even the minimal
		 * locking from the /dev/rtcN api.
		 */
		retval = rtc_read_alarm(rtc, &alm);
		if (retval < 0)
			goto close_rtc;

		alm.enabled = 1;
	} else {
		alm.enabled = 0;

		/* Provide a valid future alarm time.  Linux isn't EFI,
		 * this time won't be ignored when disabling the alarm.
		 */
		alarm = now + 300;
	}

	rtc_time_to_tm(alarm, &alm.time);
	retval = rtc_set_alarm(rtc, &alm);

close_rtc:
	rtc_class_close(rtc);
	return retval;
}
开发者ID:qkdang,项目名称:m462,代码行数:48,代码来源:auto_sleep_wakeup_test.c


示例2: omap_rtc_resume

static int omap_rtc_resume(struct platform_device *pdev)
{
	struct rtc_time rtc_tm;
	struct timespec time;

	time.tv_nsec = 0;
	omap_rtc_read_time(NULL, &rtc_tm);
	rtc_tm_to_time(&rtc_tm, &time.tv_sec);

	restore_time_delta(&rtc_delta, &time);
	if (device_may_wakeup(&pdev->dev))
		disable_irq_wake(omap_rtc_alarm);
	else
		rtc_write(irqstat, OMAP_RTC_INTERRUPTS_REG);
	return 0;
}
开发者ID:mrtos,项目名称:Logitech-Revue,代码行数:16,代码来源:rtc-omap.c


示例3: pl030_set_alarm

static int pl030_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
	struct pl030_rtc *rtc = dev_get_drvdata(dev);
	unsigned long time;
	int ret;

	/*
	 * At the moment, we can only deal with non-wildcarded alarm times.
	 */
	ret = rtc_valid_tm(&alrm->time);
	if (ret == 0)
		ret = rtc_tm_to_time(&alrm->time, &time);
	if (ret == 0)
		writel(time, rtc->base + RTC_MR);
	return ret;
}
开发者ID:33d,项目名称:linux-2.6.21-hh20,代码行数:16,代码来源:rtc-pl030.c


示例4: dryice_rtc_set_time

/*
 * set the seconds portion of dryice time counter and clear the
 * fractional part.
 */
static int dryice_rtc_set_time(struct device *dev, struct rtc_time *tm)
{
	struct rtc_drv_data *pdata = dev_get_drvdata(dev);
	unsigned long now;
	int rc;

	dev_dbg(dev, "%s\n", __func__);
	rc = rtc_tm_to_time(tm, &now);
	if (rc == 0) {
		/* zero the fractional part first */
		di_write_wait_err(pdata, 0, DTCLR, rc, err);
		di_write_wait_err(pdata, now, DTCMR, rc, err);
	}
err:
	return rc;
}
开发者ID:despierto,项目名称:imx_233_linux,代码行数:20,代码来源:rtc-imxdi.c


示例5: exynos_read_persistent_clock

/**
 * read_persistent_clock() -  Return time from a persistent clock.
 * @ts:		timespec returns a relative timestamp, not a wall time
 *
 * Reads a clock that keeps relative time across suspend/resume on Exynos
 * platforms.  The clock is accurate to 1 second.
 */
void exynos_read_persistent_clock(struct timespec *ts)
{
	struct rtc_time rtc_tm;
	unsigned long time;

	if (!exynos_rtc_base) {
		ts->tv_sec = 0;
		ts->tv_nsec = 0;
		return;
	}

	exynos_persistent_clock_read(&rtc_tm);
	rtc_tm_to_time(&rtc_tm, &time);
	ts->tv_sec = time;
	ts->tv_nsec = 0;
}
开发者ID:GAXUSXX,项目名称:G935FGaXusKernel2,代码行数:23,代码来源:exynos_persistent_clock.c


示例6: iphone_rtc_settime

static int iphone_rtc_settime(struct device *dev, struct rtc_time *rtc_tm)
{
	unsigned long secs;
	unsigned long cur;
	s32 offset;
	rtc_tm_to_time(rtc_tm, &secs);
	cur = iphone_pmu_get_epoch();
	offset = secs - cur;

	iphone_pmu_write_reg(0x6B, offset & 0xFF, 0);
	iphone_pmu_write_reg(0x6C, (offset >> 8) & 0xFF, 0);
	iphone_pmu_write_reg(0x6D, (offset >> 16) & 0xFF, 0);
	iphone_pmu_write_reg(0x6E, (offset >> 24) & 0xFF, 0);

	return 0;
}
开发者ID:fergy,项目名称:iPhone_kernel_26,代码行数:16,代码来源:pmu.c


示例7: xgene_rtc_set_alarm

static int xgene_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
	struct xgene_rtc_dev *pdata = dev_get_drvdata(dev);
	unsigned long rtc_time;
	unsigned long alarm_time;

	rtc_time = readl(pdata->csr_base + RTC_CCVR);
	rtc_tm_to_time(&alrm->time, &alarm_time);

	pdata->alarm_time = alarm_time;
	writel((u32) pdata->alarm_time, pdata->csr_base + RTC_CMR);

	xgene_rtc_alarm_irq_enable(dev, alrm->enabled);

	return 0;
}
开发者ID:mikuhatsune001,项目名称:linux2.6.32,代码行数:16,代码来源:rtc-xgene.c


示例8: au1xtoy_rtc_set_time

static int au1xtoy_rtc_set_time(struct device *dev, struct rtc_time *tm)
{
	unsigned long t;

	rtc_tm_to_time(tm, &t);

	alchemy_wrsys(t, AU1000_SYS_TOYWRITE);

	/* wait for the pending register write to succeed.  This can
	 * take up to 6 seconds...
	 */
	while (alchemy_rdsys(AU1000_SYS_CNTRCTRL) & SYS_CNTRL_C0S)
		msleep(1);

	return 0;
}
开发者ID:020gzh,项目名称:linux,代码行数:16,代码来源:rtc-au1xxx.c


示例9: rtc_sysfs_show_since_epoch

static ssize_t
rtc_sysfs_show_since_epoch(struct device *dev, struct device_attribute *attr,
		char *buf)
{
	ssize_t retval;
	struct rtc_time tm;

	retval = rtc_read_time(to_rtc_device(dev), &tm);
	if (retval == 0) {
		unsigned long time;
		rtc_tm_to_time(&tm, &time);
		retval = sprintf(buf, "%lu\n", time);
	}

	return retval;
}
开发者ID:GalaxyTab4,项目名称:android_kernel_samsung_matissewifi.bak,代码行数:16,代码来源:rtc-sysfs.c


示例10: s3c_rtc_suspend

static int s3c_rtc_suspend(struct platform_device *pdev, pm_message_t state)
{
	struct rtc_time tm;
	struct timespec time;

	time.tv_nsec = 0;
	/* save TICNT for anyone using periodic interrupts */
	ticnt_save = readb(s3c_rtc_base + S3C2410_TICNT);

	s3c_rtc_gettime(&pdev->dev, &tm);
	rtc_tm_to_time(&tm, &time.tv_sec);
	save_time_delta(&s3c_rtc_delta, &time);

	s3c_rtc_enable(pdev, 0);
	return 0;
}
开发者ID:ZhizhouTian,项目名称:s3c-linux,代码行数:16,代码来源:rtc-s3c.c


示例11: rtc_read_hw_time

unsigned long rtc_read_hw_time(void)
{
    unsigned long time, flags;
    struct rtc_time tm;

    spin_lock_irqsave(&rtc_lock, flags);
    /* rtc_ctrl_func(HAL_RTC_CMD_RELOAD, NULL); */
    /* rtc_ctrl_func(HAL_RTC_CMD_GET_TIME, &tm); */
    hal_rtc_get_tick_time(&tm);
    spin_unlock_irqrestore(&rtc_lock, flags);
    tm.tm_year += RTC_MIN_YEAR_OFFSET;
    tm.tm_mon--;
    rtc_tm_to_time(&tm, &time);
    tm.tm_wday = (time / 86400 + 4) % 7;	/* 1970/01/01 is Thursday */

    return time;
}
开发者ID:nxglabs,项目名称:mt6735-kernel-3.10.61,代码行数:17,代码来源:mtk_rtc_common.c


示例12: pcap_rtc_set_alarm

static int pcap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
	struct pcap_rtc *pcap_rtc = dev_get_drvdata(dev);
	struct rtc_time *tm = &alrm->time;
	unsigned long secs;
	u32 tod, days;

	rtc_tm_to_time(tm, &secs);

	tod = secs % SEC_PER_DAY;
	ezx_pcap_write(pcap_rtc->pcap, PCAP_REG_RTC_TODA, tod);

	days = secs / SEC_PER_DAY;
	ezx_pcap_write(pcap_rtc->pcap, PCAP_REG_RTC_DAYA, days);

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


示例13: au1xtoy_rtc_set_time

static int au1xtoy_rtc_set_time(struct device *dev, struct rtc_time *tm)
{
	unsigned long t;

	rtc_tm_to_time(tm, &t);

	au_writel(t, SYS_TOYWRITE);
	au_sync();

	/* wait for the pending register write to succeed.  This can
	 * take up to 6 seconds...
	 */
	while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C0S)
		msleep(1);

	return 0;
}
开发者ID:AD5GB,项目名称:kernel_n5_3.10-experimental,代码行数:17,代码来源:rtc-au1xxx.c


示例14: sprd_rtc_set_alarm

static int sprd_rtc_set_alarm(struct device *dev,
		struct rtc_wkalrm *alrm)
{
	unsigned long secs;
	unsigned temp;
	unsigned long read_secs;
	int i = 0,n;

	rtc_tm_to_time(&alrm->time, &secs);

	sci_adi_raw_write(ANA_RTC_INT_CLR, RTC_ALARM_BIT);

//	printk("sprd_rtc_set_alarm enable : %d,  : %lu, secs : %lu\n", alrm->enabled, secs_start_year_to_1970, secs);
//	printk("sprd_rtc_set_alarm - day [%d] hour [%d] min [%d] sec [%d]\n", alrm->time.tm_mday, alrm->time.tm_hour, alrm->time.tm_min, alrm->time.tm_sec);
	
	if(alrm->enabled){
		if(secs < secs_start_year_to_1970)
			return -1;
		temp = sci_adi_read(ANA_RTC_INT_EN);
		temp |= RTC_ALARM_BIT;
		sci_adi_raw_write(ANA_RTC_INT_EN, temp);

		secs = secs - secs_start_year_to_1970;
		wake_lock(&rtc_wake_lock);
		n = 2;
		while(sprd_rtc_set_alarm_sec(secs)!=0&&(n--)>0);
		do {
			if(i!=0){
				n = 2;
				while(sprd_rtc_set_alarm_sec(secs)!=0&&(n--)>0);
			}
			read_secs = sprd_rtc_get_alarm_sec();
			msleep(1);
			i++;
		}while(read_secs != secs && i < SPRD_RTC_SET_MAX);
		//sci_adi_raw_write(ANA_RTC_SPG_UPD, SPRD_RTC_UNLOCK);
		wake_unlock(&rtc_wake_lock);
	}else{
		sci_adi_clr(ANA_RTC_INT_EN, RTC_ALARM_BIT);
		//sci_adi_raw_write(ANA_RTC_SPG_UPD, SPRD_RTC_LOCK);
		msleep(150);
	}

	return 0;
}
开发者ID:feravolt,项目名称:Beast-Kernel-Samsung-StarPro,代码行数:45,代码来源:rtc-sprd.c


示例15: alarm_read_rtc_ring

int alarm_read_rtc_ring(int *flag, unsigned long *alarm_time)
{
    struct rtc_wkalrm rtc_alarm;
    int ret = 0;

    if (pwr_rtc_dev != NULL) {
        if (pwr_rtc_dev->dev.platform_data)
            *flag = *(int *)(pwr_rtc_dev->dev.platform_data);
        ret = rtc_read_alarm(pwr_rtc_dev, &rtc_alarm);
        if (ret < 0)
            goto out;
        rtc_tm_to_time(&rtc_alarm.time, alarm_time);
        pr_alarm(INT, "%s, flag: %d, alarm time: %lu\n",
                 __func__, *flag, *alarm_time);
    }
out:
    return ret;
}
开发者ID:dflow81,项目名称:android_kernel_samsung_goyawifi,代码行数:18,代码来源:alarm-dev.c


示例16: tegra_rtc_set_time

static int tegra_rtc_set_time(struct device *dev, struct rtc_time *tm)
{
	unsigned long now;
	int ret;

	if (hPmu == NULL)
		return -1;

	ret = rtc_tm_to_time(tm, &now);
	if (ret != 0)
		return -1;

	if (!NvOdmPmuWriteRtc(hPmu, (NvU32)now)) {
		printk("NvOdmPmuWriteRtc failed\n");
		return -1;
	}
	return 0;
}
开发者ID:BuzzBumbleBee,项目名称:android_kernel_advent_vega,代码行数:18,代码来源:rtc-tegra-odm.c


示例17: l4x_rtc_set_time

static int l4x_rtc_set_time(struct device *dev, struct rtc_time *time)
{
	u64 new_offset_to_realtime;
	long unsigned int seconds;

	rtc_tm_to_time(time, &seconds);
	new_offset_to_realtime = (u64)seconds * 1000000000 - l4rtc_get_timer();
	if (L4XV_FN_i(l4rtc_set_offset_to_realtime(rtc_server,
	                                           new_offset_to_realtime))) {
		pr_err("l4x-rtc: Could not set time.\n");
		return -EAGAIN;
	}
	/*
	 * We do not update our internal offset to realtime here. It will be
	 * updated when the rtc server sends its "time changed" IRQ.
	 */
	return 0;
}
开发者ID:michas2,项目名称:l4re-snapshot,代码行数:18,代码来源:rtc.c


示例18: mc13xxx_rtc_set_alarm

static int mc13xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
{
	struct mc13xxx_rtc *priv = dev_get_drvdata(dev);
	unsigned long s1970;
	unsigned seconds, days;
	int ret;

	mc13xxx_lock(priv->mc13xxx);

	/*                                           */
	ret = mc13xxx_reg_write(priv->mc13xxx, MC13XXX_RTCTODA, 0x1ffff);
	if (unlikely(ret))
		goto out;

	ret = mc13xxx_irq_ack(priv->mc13xxx, MC13XXX_IRQ_TODA);
	if (unlikely(ret))
		goto out;

	ret = rtc_tm_to_time(&alarm->time, &s1970);
	if (unlikely(ret))
		goto out;

	dev_dbg(dev, "%s: o%2.s %lu\n", __func__, alarm->enabled ? "n" : "ff",
			s1970);

	ret = mc13xxx_rtc_irq_enable_unlocked(dev, alarm->enabled,
			MC13XXX_IRQ_TODA);
	if (unlikely(ret))
		goto out;

	seconds = s1970 % 86400;
	days = s1970 / 86400;

	ret = mc13xxx_reg_write(priv->mc13xxx, MC13XXX_RTCDAYA, days);
	if (unlikely(ret))
		goto out;

	ret = mc13xxx_reg_write(priv->mc13xxx, MC13XXX_RTCTODA, seconds);

out:
	mc13xxx_unlock(priv->mc13xxx);

	return ret;
}
开发者ID:romanbb,项目名称:android_kernel_lge_d851,代码行数:44,代码来源:rtc-mc13xxx.c


示例19: rtc_power_off

/*
 * rtc_power_off: Set the pmic power off sequence. The RTC generates
 * pmic_pwr_enable control, which can be used to control an external
 * PMIC.
 */
static void rtc_power_off(void)
{
	u32 val;
	struct rtc_time tm;
	unsigned long time;

	/* Set PMIC power enable */
	val = readl(rtc_base + OMAP_RTC_PMIC_REG);
	writel(val | OMAP_RTC_PMIC_POWER_EN_EN, rtc_base + OMAP_RTC_PMIC_REG);

	/* Read rtc time */
	omap_rtc_read_time(NULL, &tm);

	/* Convert Gregorian date to seconds since 01-01-1970 00:00:00 */
	rtc_tm_to_time(&tm, &time);

	/* Add shutdown time to the current value */
	time += SHUTDOWN_TIME_SEC;

	/* Convert seconds since 01-01-1970 00:00:00 to Gregorian date */
	rtc_time_to_tm(time, &tm);

	if (tm2bcd(&tm) < 0)
		return;

	pr_info("System will go to power_off state in approx. %d secs\n",
			SHUTDOWN_TIME_SEC);

	/*
	 * pmic_pwr_enable is controlled by means of ALARM2 event. So here
	 * programming alarm2 expiry time and enabling alarm2 interrupt
	 */
	rtc_write(tm.tm_sec, OMAP_RTC_ALARM2_SECONDS_REG);
	rtc_write(tm.tm_min, OMAP_RTC_ALARM2_MINUTES_REG);
	rtc_write(tm.tm_hour, OMAP_RTC_ALARM2_HOURS_REG);
	rtc_write(tm.tm_mday, OMAP_RTC_ALARM2_DAYS_REG);
	rtc_write(tm.tm_mon, OMAP_RTC_ALARM2_MONTHS_REG);
	rtc_write(tm.tm_year, OMAP_RTC_ALARM2_YEARS_REG);

	/* Enable alarm2 interrupt */
	val = readl(rtc_base + OMAP_RTC_INTERRUPTS_REG);
	writel(val | OMAP_RTC_INTERRUPTS_IT_ALARM2,
				rtc_base + OMAP_RTC_INTERRUPTS_REG);
}
开发者ID:SynerconTechnologies,项目名称:FLA-Kernel,代码行数:49,代码来源:rtc-omap.c


示例20: rtc_sysfs_set_wakealarm

static ssize_t
rtc_sysfs_set_wakealarm(struct device *dev, struct device_attribute *attr,
		const char *buf, size_t n)
{
	ssize_t retval;
	unsigned long now, alarm;
	struct rtc_wkalrm alm;
	struct rtc_device *rtc = to_rtc_device(dev);

	/* Only request alarms that trigger in the future.  Disable them
	 * by writing another time, e.g. 0 meaning Jan 1 1970 UTC.
	 */
	retval = rtc_read_time(rtc, &alm.time);
	if (retval < 0)
		return retval;
	rtc_tm_to_time(&alm.time, &now);

	alarm = simple_strtoul(buf, NULL, 0);
	if (alarm > now) {
		/* Avoid accidentally clobbering active alarms; we can't
		 * entirely prevent that here, without even the minimal
		 * locking from the /dev/rtcN api.
		 */
		retval = rtc_read_alarm(rtc, &alm);
		if (retval < 0)
			return retval;
		if (alm.enabled)
			return -EBUSY;

		alm.enabled = 1;
	} else {
		alm.enabled = 0;

		/* Provide a valid future alarm time.  Linux isn't EFI,
		 * this time won't be ignored when disabling the alarm.
		 */
		alarm = now + 300;
	}
	rtc_time_to_tm(alarm, &alm.time);

	retval = rtc_set_alarm(rtc, &alm);
	return (retval < 0) ? retval : n;
}
开发者ID:Tigrouzen,项目名称:k1099,代码行数:43,代码来源:rtc-sysfs.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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