当前位置: 首页>>代码示例>>C++>>正文


C++ rtc_read函数代码示例

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


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

示例1: omap_rtc_read_alarm

static int omap_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
{
	local_irq_disable();
	rtc_wait_not_busy();

	alm->time.tm_sec = rtc_read(OMAP_RTC_ALARM_SECONDS_REG);
	alm->time.tm_min = rtc_read(OMAP_RTC_ALARM_MINUTES_REG);
	alm->time.tm_hour = rtc_read(OMAP_RTC_ALARM_HOURS_REG);
	alm->time.tm_mday = rtc_read(OMAP_RTC_ALARM_DAYS_REG);
	alm->time.tm_mon = rtc_read(OMAP_RTC_ALARM_MONTHS_REG);
	alm->time.tm_year = rtc_read(OMAP_RTC_ALARM_YEARS_REG);

	local_irq_enable();

	bcd2tm(&alm->time);
	alm->enabled = !!(rtc_read(OMAP_RTC_INTERRUPTS_REG)
			& OMAP_RTC_INTERRUPTS_IT_ALARM);

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

示例2: rtc_get_tm

void
rtc_get_tm (struct tm *tim)
{	
	u16 daysmonth[] = { 0, 0, 31, 59, 90, 120, 151, 
		181, 212, 243, 273, 304, 334 };

	/* When this bit is set, rtc is updating the count. 
	 * It gives us 244 usecs */
	while ((rtc_read (0xa) & 0x80) != 0)
		;

	tim->tm_sec = rtc_read (0);
	tim->tm_min = rtc_read (2);
	tim->tm_hour = rtc_read (4);
	tim->tm_mday = rtc_read (7);
	tim->tm_mon = rtc_read (8);
	tim->tm_year = rtc_read (9) + 2000;
		/* Century will be assumed 20. 
		 * This code doesn't always work: */
		/* + bcd2int (rtc_read (0x32)) * 100; */
	tim->tm_wday = rtc_read (6) - 1;

	tim->tm_yday = daysmonth[tim->tm_mon] + tim->tm_mday;
}
开发者ID:acceso,项目名称:jOS,代码行数:24,代码来源:rtc.c

示例3: omap_rtc_resume

static int omap_rtc_resume(struct device *dev)
{
	u8 irqwake_stat;
	struct platform_device *pdev = to_platform_device(dev);
	const struct platform_device_id *id_entry =
				platform_get_device_id(pdev);

	/* Enable the clock/module so that we can access the registers */
	pm_runtime_get_sync(dev);

	if (device_may_wakeup(dev)) {
		disable_irq_wake(omap_rtc_alarm);

		if (id_entry->driver_data & OMAP_RTC_HAS_IRQWAKEEN) {
			irqwake_stat = rtc_read(OMAP_RTC_IRQWAKEEN);
			irqwake_stat &= ~OMAP_RTC_IRQWAKEEN_ALARM_WAKEEN;
			rtc_write(irqwake_stat, OMAP_RTC_IRQWAKEEN);
		}
	} else {
		rtc_write(irqstat, OMAP_RTC_INTERRUPTS_REG);
	}
	return 0;
}
开发者ID:03199618,项目名称:linux,代码行数:23,代码来源:rtc-omap.c

示例4: omap_rtc_suspend

static int omap_rtc_suspend(struct platform_device *pdev, pm_message_t state)
{
	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);

	save_time_delta(&rtc_delta, &time);
	irqstat = rtc_read(OMAP_RTC_INTERRUPTS_REG);

	/* FIXME the RTC alarm is not currently acting as a wakeup event
	 * source, and in fact this enable() call is just saving a flag
	 * that's never used...
	 */
	if (device_may_wakeup(&pdev->dev))
		enable_irq_wake(omap_rtc_alarm);
	else
		rtc_write(0, OMAP_RTC_INTERRUPTS_REG);

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

示例5: main

 int main() 
 {
    time_t seconds;
    struct tm *timeinfo;
    
    rtc_init();
    rtc_write(1256729737);  // Set RTC time to Wed, 28 Oct 2009 11:35:37

    while(1) {
        seconds = rtc_read();
        timeinfo = localtime(&seconds);

        DBG_8195A("Time as seconds since January 1, 1970 = %d\n", seconds);

        DBG_8195A("Time as a basic string = %s", ctime(&seconds));

        DBG_8195A("Time as a custom formatted string = %d-%d-%d %d:%d:%d ", 
            timeinfo->tm_year, timeinfo->tm_mon, timeinfo->tm_mday, timeinfo->tm_hour,
            timeinfo->tm_min,timeinfo->tm_sec);

        wait(1);
    }
 }
开发者ID:KuanYuChen,项目名称:ameba-sdk-gcc-make,代码行数:23,代码来源:main.c

示例6: omap_rtc_suspend

static int omap_rtc_suspend(struct device *dev)
{
	struct omap_rtc *rtc = dev_get_drvdata(dev);

	rtc->interrupts_reg = rtc_read(rtc, OMAP_RTC_INTERRUPTS_REG);

	rtc->type->unlock(rtc);
	/*
	 * FIXME: the RTC alarm is not currently acting as a wakeup event
	 * source on some platforms, and in fact this enable() call is just
	 * saving a flag that's never used...
	 */
	if (device_may_wakeup(dev))
		enable_irq_wake(rtc->irq_alarm);
	else
		rtc_write(rtc, OMAP_RTC_INTERRUPTS_REG, 0);
	rtc->type->lock(rtc);

	/* Disable the clock/module */
	pm_runtime_put_sync(dev);

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

示例7: omap_rtc_remove

static int __exit omap_rtc_remove(struct platform_device *pdev)
{
	struct omap_rtc *rtc = platform_get_drvdata(pdev);
	u8 reg;

	if (pm_power_off == omap_rtc_power_off &&
			omap_rtc_power_off_rtc == rtc) {
		pm_power_off = NULL;
		omap_rtc_power_off_rtc = NULL;
	}

	device_init_wakeup(&pdev->dev, 0);

	if (!IS_ERR(rtc->clk))
		clk_disable_unprepare(rtc->clk);

	rtc->type->unlock(rtc);
	/* leave rtc running, but disable irqs */
	rtc_write(rtc, OMAP_RTC_INTERRUPTS_REG, 0);

	if (rtc->has_ext_clk) {
		reg = rtc_read(rtc, OMAP_RTC_OSC_REG);
		reg &= ~OMAP_RTC_OSC_SEL_32KCLK_SRC;
		rtc_write(rtc, OMAP_RTC_OSC_REG, reg);
	}

	rtc->type->lock(rtc);

	/* Disable the clock/module */
	pm_runtime_put_sync(&pdev->dev);
	pm_runtime_disable(&pdev->dev);

	/* Remove ext_wakeup pinconf */
	pinctrl_unregister(rtc->pctldev);

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

示例8: omap_rtc_read_time

static int omap_rtc_read_time(struct device *dev, struct rtc_time *tm)
{
	/* we don't report wday/yday/isdst ... */
	local_irq_disable();
	rtc_wait_not_busy();

	tm->tm_sec = rtc_read(OMAP_RTC_SECONDS_REG);
	tm->tm_min = rtc_read(OMAP_RTC_MINUTES_REG);
	tm->tm_hour = rtc_read(OMAP_RTC_HOURS_REG);
	tm->tm_mday = rtc_read(OMAP_RTC_DAYS_REG);
	tm->tm_mon = rtc_read(OMAP_RTC_MONTHS_REG);
	tm->tm_year = rtc_read(OMAP_RTC_YEARS_REG);

	local_irq_enable();

	bcd2tm(tm);
	return 0;
}
开发者ID:119-org,项目名称:hi3518-osdrv,代码行数:18,代码来源:rtc-omap.c

示例9: rtc_irq

static irqreturn_t rtc_irq(int irq, void *dev_id)
{
	struct omap_rtc	*rtc = dev_id;
	unsigned long events = 0;
	u8 irq_data;

	irq_data = rtc_read(rtc, OMAP_RTC_STATUS_REG);

	/* alarm irq? */
	if (irq_data & OMAP_RTC_STATUS_ALARM) {
		rtc->type->unlock(rtc);
		rtc_write(rtc, OMAP_RTC_STATUS_REG, OMAP_RTC_STATUS_ALARM);
		rtc->type->lock(rtc);
		events |= RTC_IRQF | RTC_AF;
	}

	/* 1/sec periodic/update irq? */
	if (irq_data & OMAP_RTC_STATUS_1S_EVENT)
		events |= RTC_IRQF | RTC_UF;

	rtc_update_irq(rtc->rtc, 1, events);

	return IRQ_HANDLED;
}
开发者ID:forgivemyheart,项目名称:linux,代码行数:24,代码来源:rtc-omap.c

示例10: rtc_gettimeofday

/*
 * Return current RTC time. Note that due to waiting for the update cycle to
 * complete, this call may take some time.
 */
static uint64_t rtc_gettimeofday(void) {
    struct bmk_clock_ymdhms dt;

    interrupts_disable();

    /*
     * If RTC_UIP is down, we have at least 244us to obtain a
     * consistent reading before an update can occur.
     */
    while (rtc_read(RTC_STATUS_A) & RTC_UIP)
        continue;

    dt.dt_sec = bcdtobin(rtc_read(RTC_SEC));
    dt.dt_min = bcdtobin(rtc_read(RTC_MIN));
    dt.dt_hour = bcdtobin(rtc_read(RTC_HOUR));
    dt.dt_day = bcdtobin(rtc_read(RTC_DAY));
    dt.dt_mon = bcdtobin(rtc_read(RTC_MONTH));
    dt.dt_year = bcdtobin(rtc_read(RTC_YEAR)) + 2000;

    interrupts_enable();

    return clock_ymdhms_to_secs(&dt) * NSEC_PER_SEC;
}
开发者ID:hannesm,项目名称:solo5,代码行数:27,代码来源:tscclock.c

示例11: omap_rtc_read_alarm

static int omap_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
{
	struct omap_rtc *rtc = dev_get_drvdata(dev);
	u8 interrupts;

	local_irq_disable();
	rtc_wait_not_busy(rtc);

	alm->time.tm_sec = rtc_read(rtc, OMAP_RTC_ALARM_SECONDS_REG);
	alm->time.tm_min = rtc_read(rtc, OMAP_RTC_ALARM_MINUTES_REG);
	alm->time.tm_hour = rtc_read(rtc, OMAP_RTC_ALARM_HOURS_REG);
	alm->time.tm_mday = rtc_read(rtc, OMAP_RTC_ALARM_DAYS_REG);
	alm->time.tm_mon = rtc_read(rtc, OMAP_RTC_ALARM_MONTHS_REG);
	alm->time.tm_year = rtc_read(rtc, OMAP_RTC_ALARM_YEARS_REG);

	local_irq_enable();

	bcd2tm(&alm->time);

	interrupts = rtc_read(rtc, OMAP_RTC_INTERRUPTS_REG);
	alm->enabled = !!(interrupts & OMAP_RTC_INTERRUPTS_IT_ALARM);

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

示例12: rtc_get

int rtc_get(struct rtc_time *rtc)
{
	uchar sec, min, hour, mday, month, year;

	/* Reading counts register latches the current RTC calendar count.
	 * This guranties the coherence of the read during aprox 500 ms */
	sec = rtc_read (DA9052_COUNTS_REG);
	if (!(sec & DA9052_COUNTS_MONITOR)) {
		puts("*** ERROR: " DEV_NAME " - incorrect date/time (Power was lost)\n");
	}
	min = rtc_read (DA9052_COUNTMI_REG);
	hour = rtc_read (DA9052_COUNTH_REG);
	mday = rtc_read (DA9052_COUNTD_REG);
	month = rtc_read (DA9052_COUNTMO_REG);
	year = rtc_read (DA9052_COUNTY_REG);

	DBG ("Get RTC year: %02d mon: %02d mday: %02d "
		"hr: %02d min: %02d sec: %02d\n",
		year, month, mday, hour, min, sec);

	rtc->tm_sec  = sec & DA9052_COUNTS_COUNTSEC;
	rtc->tm_min  = min & DA9052_COUNTMI_COUNTMIN;
	rtc->tm_hour = hour & DA9052_COUNTH_COUNTHOUR;
	rtc->tm_mday = mday & DA9052_COUNTD_COUNTDAY;
	rtc->tm_mon  = month & DA9052_COUNTMO_COUNTMONTH;
	rtc->tm_year = (year & DA9052_COUNTY_COUNTYEAR) + 2000;

	/* Compute the the day of week, not available in the RTC registers */
	GregorianDay(rtc);

	DBG ("Get DATE: %4d-%02d-%02d   TIME: %2d:%02d:%02d\n",
		rtc->tm_year, rtc->tm_mon, rtc->tm_mday,
		rtc->tm_hour, rtc->tm_min, rtc->tm_sec);

	return 0;
}
开发者ID:digidotcom,项目名称:yocto-uboot,代码行数:36,代码来源:da905x.c

示例13: ds1511_rtc_set_time

/*
 * set the rtc chip's idea of the time.
 * stupidly, some callers call with year unmolested;
 * and some call with  year = year - 1900.  thanks.
 */
static int ds1511_rtc_set_time(struct device *dev, struct rtc_time *rtc_tm)
{
	u8 mon, day, dow, hrs, min, sec, yrs, cen;
	unsigned long flags;

	/*
	 * won't have to change this for a while
	 */
	if (rtc_tm->tm_year < 1900) {
		rtc_tm->tm_year += 1900;
	}

	if (rtc_tm->tm_year < 1970) {
		return -EINVAL;
	}
	yrs = rtc_tm->tm_year % 100;
	cen = rtc_tm->tm_year / 100;
	mon = rtc_tm->tm_mon + 1;   /* tm_mon starts at zero */
	day = rtc_tm->tm_mday;
	dow = rtc_tm->tm_wday & 0x7; /* automatic BCD */
	hrs = rtc_tm->tm_hour;
	min = rtc_tm->tm_min;
	sec = rtc_tm->tm_sec;

	if ((mon > 12) || (day == 0)) {
		return -EINVAL;
	}

	if (day > rtc_month_days(rtc_tm->tm_mon, rtc_tm->tm_year)) {
		return -EINVAL;
	}

	if ((hrs >= 24) || (min >= 60) || (sec >= 60)) {
		return -EINVAL;
	}

	/*
	 * each register is a different number of valid bits
	 */
	sec = bin2bcd(sec) & 0x7f;
	min = bin2bcd(min) & 0x7f;
	hrs = bin2bcd(hrs) & 0x3f;
	day = bin2bcd(day) & 0x3f;
	mon = bin2bcd(mon) & 0x1f;
	yrs = bin2bcd(yrs) & 0xff;
	cen = bin2bcd(cen) & 0xff;

	spin_lock_irqsave(&ds1511_lock, flags);
	rtc_disable_update();
	rtc_write(cen, RTC_CENTURY);
	rtc_write(yrs, RTC_YEAR);
	rtc_write((rtc_read(RTC_MON) & 0xe0) | mon, RTC_MON);
	rtc_write(day, RTC_DOM);
	rtc_write(hrs, RTC_HOUR);
	rtc_write(min, RTC_MIN);
	rtc_write(sec, RTC_SEC);
	rtc_write(dow, RTC_DOW);
	rtc_enable_update();
	spin_unlock_irqrestore(&ds1511_lock, flags);

	return 0;
}
开发者ID:AdrianHuang,项目名称:linux-3.8.13,代码行数:67,代码来源:rtc-ds1511.c

示例14: main

int main(void)
{
  uart_t *u0;

  /* Delay for one second to avoid multiple resets during programming. */
  _delay_ms(1000);

  /* Initialize USART0 and set up stdout to write to it. */
  u0 = uart_init("0", UART_BAUD_SELECT(38400, F_CPU));
  uart_init_stdout(u0);
  uart_set_rx_callback(u0, notice_uart_input);

  i2c_init();

  /*
   * Test if pullup is required on the I2C pins, and enable if the pins are
   * reading low. This allows external pullups to optionally be used, so that
   * for example the I2C bus can be pulled up to 3.3V to allow communication
   * between 3.3V and 5V devices at 3.3V.
   */
  if((PINC & (_BV(PC0) | _BV(PC1))) == 0)
  {
    DDRC  = _BV(PC0) | _BV(PC1);
    PORTC = _BV(PC0) | _BV(PC1);
  }

  sei();

  printf_P(PSTR("\n\nBooted!\n"));

  printf_P(PSTR("Reading saved configuration...\n\n"));
  configuration_restore();

  printf_P(PSTR(
    "Configuration:\n"
    "  tz_offset:  %2i\n"
    "  dst_offset: %2i\n"
    "\n"
  ), configuration.tz_offset, configuration.dst_offset);

  printf_P(PSTR(
    "Commands:\n"
    "  Get the current time:\n"
    "    G\n"
    "  Set the current time:\n"
    "    S YYYY-MM-DD hh:mm:ss\n"
    "  Set the timezone offset from UTC:\n"
    "    O <tz_offset> <dst_offset>\n"
    "  Set the time from GPS (if available):"
    "    s\n"
    "\n"
  ));

  rtc_init(rtc);
  rtc_sqw_enable(rtc);
  rtc_sqw_rate(rtc, 1);

  /* Enable pullup and interrupt for PC6/PCINT22, DS1307 SQW pin. */
  PORTC  |= _BV(PC6);
  PCMSK2 |= _BV(PCINT22);
  PCICR  |= _BV(PCIE2);

  /* Initialize the sequencer with 1000Hz tick rate. */
  led_sequencer_init(1000);

  /* Initialize and load the LED Analog Clock LED display. */
  led_charlieplex_init(&LED_DISPLAY);
  led_sequencer_push_front_matrix("c", &LED_DISPLAY);

  /*
   * Add empty sequences for hour, minute, second, hourly show, and minutely
   * show.
   */
  led_sequencer_push_back_sequence("h");
  led_sequencer_push_back_sequence("m");
  led_sequencer_push_back_sequence("s");
  led_sequencer_push_back_sequence("H");
  led_sequencer_push_back_sequence("M");

  /*
   * Initially read the time, set last_* for use later, and push a sequencer
   * step into the second, minute, and hour sequences.  The steps pushed
   * below are never removed, as they are modified in place in update_hms()
   * with each time change.
   */
  rtc_read(rtc, &current_time);
  last_hour   = current_time.hour;
  last_minute = current_time.minute;
  last_second = current_time.second;
  step_hour   = led_sequencer_sequence_push_back_step("h", LED_SEQUENCER_STEP_SHOW, "c", led_mapping_qhour[((current_time.hour % 12) * 4) + (current_time.minute / 15)], 255);
  step_minute = led_sequencer_sequence_push_back_step("m", LED_SEQUENCER_STEP_SHOW, "c", led_mapping_minute[current_time.minute], 255);
  step_second = led_sequencer_sequence_push_back_step("s", LED_SEQUENCER_STEP_SHOW, "c", led_mapping_minute[current_time.second], 255);

  enqueue_hourly_show();

  led_sequencer_run();

  srand(current_time.hour * current_time.minute * current_time.second);

  /*
//.........这里部分代码省略.........
开发者ID:jeremycole,项目名称:avr,代码行数:101,代码来源:led_analog_clock.c

示例15: rtc_get

int rtc_get( struct rtc_time *tmp)
{
	if (phantom_flag < 0)
		phantom_flag = get_phantom_flag();

	if (phantom_flag)
	{
		unsigned char rtc[8];

		phantom_rtc_read(RTC_BASE, rtc);

		tmp->tm_sec	= bcd2bin(rtc[1] & 0x7f);
		tmp->tm_min	= bcd2bin(rtc[2] & 0x7f);
		tmp->tm_hour	= bcd2bin(rtc[3] & 0x1f);
		tmp->tm_wday	= bcd2bin(rtc[4] & 0x7);
		tmp->tm_mday	= bcd2bin(rtc[5] & 0x3f);
		tmp->tm_mon	= bcd2bin(rtc[6] & 0x1f);
		tmp->tm_year	= bcd2bin(rtc[7]) + 1900;
		tmp->tm_yday = 0;
		tmp->tm_isdst = 0;

		if( (rtc[3] & 0x80)  && (rtc[3] & 0x40) ) tmp->tm_hour += 12;
		if (tmp->tm_year < 1970) tmp->tm_year += 100;
	} else {
		uchar sec, min, hour;
		uchar mday, wday, mon, year;

		int century;

		uchar reg_a;

		if (century_flag < 0)
			century_flag = get_century_flag();

		reg_a = rtc_read( RTC_CONTROLA );
		/* lock clock registers for read */
		rtc_write( RTC_CONTROLA, ( reg_a | RTC_CA_READ ));

		sec     = rtc_read( RTC_SECONDS );
		min     = rtc_read( RTC_MINUTES );
		hour    = rtc_read( RTC_HOURS );
		mday    = rtc_read( RTC_DAY_OF_MONTH );
		wday    = rtc_read( RTC_DAY_OF_WEEK );
		mon     = rtc_read( RTC_MONTH );
		year    = rtc_read( RTC_YEAR );
		century = rtc_read( RTC_CENTURY );

		/* unlock clock registers after read */
		rtc_write( RTC_CONTROLA, ( reg_a & ~RTC_CA_READ ));

		tmp->tm_sec  = bcd2bin( sec  & 0x7F );
		tmp->tm_min  = bcd2bin( min  & 0x7F );
		tmp->tm_hour = bcd2bin( hour & 0x3F );
		tmp->tm_mday = bcd2bin( mday & 0x3F );
		tmp->tm_mon  = bcd2bin( mon & 0x1F );
		tmp->tm_wday = bcd2bin( wday & 0x07 );

		if (century_flag) {
			tmp->tm_year = bcd2bin( year ) +
				( bcd2bin( century & 0x3F ) * 100 );
		} else {
			tmp->tm_year = bcd2bin( year ) + 1900;
			if (tmp->tm_year < 1970) tmp->tm_year += 100;
		}

		tmp->tm_yday = 0;
		tmp->tm_isdst= 0;
	}

	return 0;
}
开发者ID:cmp1084,项目名称:u-boot,代码行数:71,代码来源:phantom.c


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