本文整理汇总了C++中rtc_set_time函数的典型用法代码示例。如果您正苦于以下问题:C++ rtc_set_time函数的具体用法?C++ rtc_set_time怎么用?C++ rtc_set_time使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rtc_set_time函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rtc_ioctl
static int
rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
unsigned long arg)
{
struct rtc_time rtc_tm;
ulong curr_time;
switch (cmd) {
case RTC_RD_TIME: /* Read the time/date from RTC */
curr_time = rtc_get_time();
to_tm(curr_time, &rtc_tm);
rtc_tm.tm_year -= 1900;
return copy_to_user((void *) arg, &rtc_tm, sizeof(rtc_tm)) ?
-EFAULT : 0;
case RTC_SET_TIME: /* Set the RTC */
if (!capable(CAP_SYS_TIME))
return -EACCES;
if (copy_from_user(&rtc_tm,
(struct rtc_time *) arg,
sizeof(struct rtc_time)))
return -EFAULT;
curr_time = mktime(rtc_tm.tm_year + 1900,
rtc_tm.tm_mon,
rtc_tm.tm_mday,
rtc_tm.tm_hour,
rtc_tm.tm_min,
rtc_tm.tm_sec);
return rtc_set_time(curr_time);
default:
return -EINVAL;
}
}
示例2: alarm_set_rtc
static int alarm_set_rtc(struct timespec *ts)
{
struct rtc_time new_rtc_tm;
struct rtc_device *rtc_dev;
unsigned long flags;
int rv = 0;
rtc_time_to_tm(ts->tv_sec, &new_rtc_tm);
alarm_dbg(INFO, "set rtc %ld %ld - rtc %02d:%02d:%02d %02d/%02d/%04d\n",
ts->tv_sec, ts->tv_nsec,
new_rtc_tm.tm_hour, new_rtc_tm.tm_min,
new_rtc_tm.tm_sec, new_rtc_tm.tm_mon + 1,
new_rtc_tm.tm_mday,
new_rtc_tm.tm_year + 1900);
rtc_dev = alarmtimer_get_rtcdev();
rv = do_settimeofday(ts);
if (rv < 0)
return rv;
if (rtc_dev)
rv = rtc_set_time(rtc_dev, &new_rtc_tm);
spin_lock_irqsave(&alarm_slock, flags);
alarm_pending |= ANDROID_ALARM_TIME_CHANGE_MASK;
wake_up(&alarm_wait_queue);
spin_unlock_irqrestore(&alarm_slock, flags);
return rv;
}
示例3: rtc_reset
static void
rtc_reset(void)
{
struct rtc_date dt;
struct rtc_time tm;
RTC_ALRM_DIS();
// Set date and time
dt.ten_cent = 0;
dt.cent = 0;
dt.ten_yr = 0;
dt.yr = 0;
dt.ten_mth = 0;
dt.mth = 0;
dt.ten_day = 0;
dt.day = 0;
tm.dow = 0;
tm.ten_hr = 0;
tm.hr = 0;
tm.ten_min = 0;
tm.min = 0;
tm.ten_sec = 0;
tm.sec = 0;
tm.sos = 0;
rtc_set_date(&dt);
rtc_set_time(&tm);
}
示例4: rtc_sub_alarm_test
static int
rtc_sub_alarm_test(u32 f_time, u32 f_date)
{
volatile int hit;
int result = 0;
rtc_reset();
printf("RTC Time = W%d %d%d:%d%d:%d%d:%d\n", tm.dow, tm.ten_hr, tm.hr, \
tm.ten_min, tm.min, tm.ten_sec, tm.sec, tm.sos);
printf("RTC Date = C%d%d %d%d/%d%d/%d%d\n", dt.ten_cent, dt.cent, dt.ten_yr, dt.yr, \
dt.ten_mth, dt.mth, dt.ten_day, dt.day);
printf("Alarm Time = W%d %d%d:%d%d:%d%d:%d\n", tm_a.dow, tm_a.ten_hr, tm_a.hr, \
tm_a.ten_min, tm_a.min, tm_a.ten_sec, tm_a.sec, tm_a.sos);
printf("Alarm Date = C%d%d %d%d/%d%d/%d%d\n", dt_a.ten_cent, dt_a.cent, dt_a.ten_yr, dt_a.yr, \
dt_a.ten_mth, dt_a.mth, dt_a.ten_day, dt_a.day);
printf("Alarm Time on: ");
if (f_time & SOCLE_RTC_TALRM_CSOS)
printf("\"Sixteen of Second\" ");
if (f_time & SOCLE_RTC_TALRM_CS)
printf("\"Second\" ");
if (f_time & SOCLE_RTC_TALRM_CM)
printf("\"Minute\" ");
if (f_time & SOCLE_RTC_TALRM_CH)
printf("\"Hour\" ");
if (f_time & SOCLE_RTC_TALRM_CDOW)
printf("\"Day of Week\"");
printf("\n");
printf("Alarm Date on: ");
if (f_date & SOCLE_RTC_DALRM_CD)
printf("\"Day\" ");
if (f_date & SOCLE_RTC_DALRM_CM)
printf("\"Month\" ");
if (f_date & SOCLE_RTC_DALRM_CY)
printf("\"Year\" ");
if (f_date & SOCLE_RTC_DALRM_CC)
printf("\"Century\"");
printf("\n");
rtc_set_time_alarm(&tm_a, f_time);
rtc_set_date_alarm(&dt_a, f_date);
hit = 0;
rtc_set_date(&dt);
rtc_set_time(&tm);
printf("alarm after 15 second...\n");
return result;
}
示例5: rtc_hctosys
static int __init rtc_hctosys(void)
{
int err = -ENODEV;
struct rtc_time tm;
struct timespec tv = {
.tv_nsec = NSEC_PER_SEC >> 1,
};
struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
if (rtc == NULL) {
pr_err("%s: unable to open rtc device (%s)\n",
__FILE__, CONFIG_RTC_HCTOSYS_DEVICE);
goto err_open;
}
err = rtc_read_time(rtc, &tm);
if (err) {
dev_err(rtc->dev.parent,
"hctosys: unable to read the hardware clock\n");
goto err_read;
}
err = rtc_valid_tm(&tm);
if (err) {
dev_err(rtc->dev.parent,
"hctosys: invalid date/time\n");
goto err_invalid;
}
if(tm.tm_year < 100) {
tm.tm_year += 13;
rtc_set_time(rtc, &tm);
}
rtc_tm_to_time(&tm, &tv.tv_sec);
do_settimeofday(&tv);
dev_info(rtc->dev.parent,
"setting system clock to "
"%d-%02d-%02d %02d:%02d:%02d UTC (%u)\n",
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec,
(unsigned int) tv.tv_sec);
err_invalid:
err_read:
rtc_class_close(rtc);
rtc_hctohc(tm);
err_open:
rtc_hctosys_ret = err;
return err;
}
late_initcall(rtc_hctosys);
示例6: _rtc_settime
static void _rtc_settime(char **argv)
{
struct tm now;
if (_parse_time(argv, &now) == 0) {
if (rtc_set_time(&now) == -1) {
puts("rtc: error setting time");
}
}
}
示例7: set_timestamp
void set_timestamp(uint32_t time)
{
#ifdef RTC
rtc_set_time(time);
#else
ATOMIC_BLOCK(ATOMIC_FORCEON)
{
timestamp = time;
}
#endif
}
示例8: set_rtc_time
int set_rtc_time(struct rtc_time *time)
{
unsigned long nowtime;
int ret;
spin_lock(&mips_rtc_lock);
nowtime = mktime(time->tm_year+1900, time->tm_mon+1,
time->tm_mday, time->tm_hour, time->tm_min,
time->tm_sec);
ret = rtc_set_time(nowtime);
spin_unlock(&mips_rtc_lock);
return ret;
}
示例9: s3c_rtc_settime
static int s3c_rtc_settime(struct device *dev, struct rtc_time *tm)
{
void __iomem *base = s3c_rtc_base;
// int year = tm->tm_year;//- 100;
int year = tm->tm_year-100;
#ifdef CONFIG_RTC_DRV_S5M
struct rtc_device *rtc1 ;
#endif
printk("%s() %d-%d-%d %d:%d:%d\n", __FUNCTION__,
tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
pr_debug("set time %04d.%02d.%02d %02d:%02d:%02d\n",
1900 + tm->tm_year, tm->tm_mon+1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
/* we get around y2k by simply not supporting it */
// printk("year %d\n",year);
// if (year < 70) {
// dev_err(dev, "rtc only supports from year 1970\n");
// return -EINVAL;
// }
writeb(bin2bcd(tm->tm_sec), base + S3C2410_RTCSEC);
writeb(bin2bcd(tm->tm_min), base + S3C2410_RTCMIN);
writeb(bin2bcd(tm->tm_hour), base + S3C2410_RTCHOUR);
writeb(bin2bcd(tm->tm_mday), base + S3C2410_RTCDATE);
writeb(bin2bcd(tm->tm_mon + 1), base + S3C2410_RTCMON);
writeb(bin2bcd(year), base + S3C2410_RTCYEAR);
#ifdef CONFIG_RTC_DRV_S5M
rtc1 = rtc_class_open("rtc1");
if(rtc1 == NULL)
{
pr_err("!!!!!! %s: unable to open rtc1 device!!!!!\n",
__FILE__);
}
else
{
rtc_set_time(rtc1,tm);
rtc_class_close(rtc1);
}
#endif
return 0;
}
示例10: rtc_set_time_test
extern int
rtc_set_time_test(int autotest)
{
rtc_time_t time;
printf("Please input the RTC time, ex: on Monday, 5:30:40:00 PM\n");
printf("Set Time = 1:17:30:40:00, Your Time = ");
scanf("%d:%1d%1d:%1d%1d:%1d%1d:%d", &time.dow, &time.ten_hr, &time.hr, \
&time.ten_min, &time.min, &time.ten_sec, &time.sec, &time.sos);
PDEBUG("Input Time = %d:%d%d:%d%d:%d%d:%d\n", time.dow, time.ten_hr, time.hr, \
time.ten_min, time.min, time.ten_sec, time.sec, time.sos);
rtc_set_time(&time);
return 0;
}
示例11: rt_timer_interrupt
void rt_timer_interrupt(struct pt_regs *regs)
{
int cpu = smp_processor_id();
int cpuA = ((cputoslice(cpu)) == 0);
int irq = 9; /* XXX Assign number */
irq_enter();
write_seqlock(&xtime_lock);
again:
LOCAL_HUB_S(cpuA ? PI_RT_PEND_A : PI_RT_PEND_B, 0); /* Ack */
ct_cur[cpu] += CYCLES_PER_JIFFY;
LOCAL_HUB_S(cpuA ? PI_RT_COMPARE_A : PI_RT_COMPARE_B, ct_cur[cpu]);
if (LOCAL_HUB_L(PI_RT_COUNT) >= ct_cur[cpu])
goto again;
kstat_this_cpu.irqs[irq]++; /* kstat only for bootcpu? */
if (cpu == 0)
do_timer(regs);
#ifdef CONFIG_SMP
update_process_times(user_mode(regs));
#endif /* CONFIG_SMP */
/*
* If we have an externally synchronized Linux clock, then update
* RTC clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
* called as close as possible to when a second starts.
*/
if ((time_status & STA_UNSYNC) == 0 &&
xtime.tv_sec > last_rtc_update + 660 &&
(xtime.tv_nsec / 1000) >= 500000 - ((unsigned) TICK_SIZE) / 2 &&
(xtime.tv_nsec / 1000) <= 500000 + ((unsigned) TICK_SIZE) / 2) {
if (rtc_set_time(xtime.tv_sec) == 0) {
last_rtc_update = xtime.tv_sec;
} else {
last_rtc_update = xtime.tv_sec - 600;
/* do it again in 60 s */
}
}
write_sequnlock(&xtime_lock);
irq_exit();
}
示例12: main
void main(void)
{
struct tm timeinfo;
rtc_init();
// Give RTC a initial value: 2015/4/15 (Wed) 12:00:00
rtc_set_time(2015, 4, 15, 3, 12, 0, 0);
while (1) {
rtc_read_time(&timeinfo);
DBG_8195A("%d-%d-%d[%d] %d:%d:%d\r\n", timeinfo.tm_year, timeinfo.tm_mon, timeinfo.tm_mday,
timeinfo.tm_wday, timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec);
wait_ms(1000);
}
rtc_deinit();
}
示例13: configure_rtc
/**
* \brief Configure RTC for test
* \Set alarm ewery second
*/
void configure_rtc (void)
{
uint32_t status;
struct _time MTU = {00, 00, 00};
struct _time MTA = {18, 30, 00};
struct _date MDT = {2015, 06, 01, 1};
rtc_set_hour_mode(0); // mode 24h
status = rtc_set_time(&MTU);
status |= rtc_set_date(&MDT);
status |= rtc_set_time_alarm(&MTA);
status |= rtc_set_time_event (RTC_CR_TIMEVSEL_MINUTE);
rtc_disable_it (RTC_IER_ACKEN | RTC_IER_ALREN | RTC_IER_SECEN | RTC_IER_TIMEN | RTC_IER_CALEN);
rtc_enable_it (RTC_IER_SECEN);
aic_set_source_vector(ID_SYSC, rtc_irq_handler);
aic_enable(ID_SYSC);
}
示例14: rtc_post_load
static int rtc_post_load(void *opaque, int version_id)
{
RTCState *s = opaque;
if (version_id <= 2) {
rtc_set_time(s);
s->offset = 0;
check_update_timer(s);
}
#ifdef TARGET_I386
if (version_id >= 2) {
if (s->lost_tick_policy == LOST_TICK_SLEW) {
rtc_coalesced_timer_update(s);
}
}
#endif
return 0;
}
示例15: setDateTime
/**
* RTCの時間を設定します。
*
* @param[in] year 年を指定します。
* @param[in] mon 月を指定します。
* @param[in] day 日を指定します。
* @param[in] hour 時を指定します。
* @param[in] min 分を指定します。
* @param[in] sec 秒を指定します。
* @param[in] week 曜日を指定します。
*
* @return 時間の設定に成功した場合はtrueを返却します。失敗した場合はfalseを返却します。
*
* @attention なし
***************************************************************************/
bool RTC::setDateTime(int year, int mon, int day, int hour, int min, int sec, int week)
{
bool bError = true;
RTC_TIMETYPE time;
time.year = year;
time.mon = mon;
time.day = day;
time.hour = hour;
time.min = min;
time.second = sec;
time.weekday= week;
if (rtc_set_time(&time) == 0) {
bError = false;
}
return (bError);
}