本文整理汇总了C++中rtc_read函数的典型用法代码示例。如果您正苦于以下问题:C++ rtc_read函数的具体用法?C++ rtc_read怎么用?C++ rtc_read使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rtc_read函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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, ¤t_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
示例16: timer_sync_time
void timer_sync_time( void )
{
current_time = rtc_read();
}
开发者ID:Caleb1994,项目名称:stewieos,代码行数:4,代码来源:timer.c
示例17: update_hms
/**
* Update the "h", "m", and "s" sequences, optionally queuing an animation
* into "H" or "M" sequences, depending on the new time. This function is
* called once per second during the main loop after the interrupt triggered
* by the time change marks update_hms_ready.
*
* The "h", "m", and "s" sequences are updated in-place in order to avoid
* additional work and possible memory fragmentation from removing and
* re-enqueuing the applicable LED.
*/
void update_hms(void)
{
uint8_t rc;
rtc_datetime_24h_t offset_time;
if(++time_elapsed_since_gps_sync > 1777)
{
printf_P(PSTR("Maximum time limit exceeded since last GPS sync, syncing...\n"));
command_set_from_gps();
time_elapsed_since_gps_sync = 0;
}
rc = rtc_read(rtc, ¤t_time);
if(rc) return;
rtc_offset_time(¤t_time, &offset_time,
configuration.tz_offset + configuration.dst_offset);
if(current_time.hour != last_hour)
{
configuration.dst_offset = rtc_find_dst_offset(offset_time, usa_dst_dates);
rtc_offset_time(¤t_time, &offset_time,
configuration.tz_offset + configuration.dst_offset);
}
led_sequencer_halt();
/*
* If the second has changed since the last time the time was checked,
* we should update the "second", "minute, and "hour" sequences. In practice
* this is nearly always the case, since the interrupts ensure we're only
* really called when needed.
*/
if(current_time.second != last_second)
{
led_sequencer_sequence_modify_step(step_second, led_mapping_minute[offset_time.second], 255);
led_sequencer_sequence_modify_step(step_minute, led_mapping_minute[offset_time.minute], 255);
led_sequencer_sequence_modify_step(step_hour, led_mapping_qhour[((offset_time.hour % 12) * 4) + (offset_time.minute / 15)], 255);
enqueue_secondly_show();
last_second = current_time.second;
}
/* Do something nice for New Years */
if(offset_time.month == 1 && offset_time.date == 1
&& offset_time.hour == 0 && offset_time.minute == 0
&& offset_time.second == 0)
{
enqueue_nye_show();
last_hour = current_time.hour;
last_minute = current_time.minute;
}
/*
* If the hour has changed, enqueue the hourly show.
*/
else if(current_time.hour != last_hour)
{
enqueue_hourly_show();
last_hour = current_time.hour;
}
/*
* If the hour is still the same, enqueue the minutely show.
*/
else if(current_time.minute != last_minute)
{
enqueue_minutely_show();
last_minute = current_time.minute;
}
led_sequencer_run();
update_gps();
write_remote_lcd(&offset_time, gps_data.gps_signal_strength);
}
开发者ID:jeremycole,项目名称:avr,代码行数:84,代码来源:led_analog_clock.c
示例18: omap_rtc_probe
static int __init omap_rtc_probe(struct platform_device *pdev)
{
struct resource *res, *mem;
struct rtc_device *rtc;
u8 reg, new_ctrl;
omap_rtc_timer = platform_get_irq(pdev, 0);
if (omap_rtc_timer <= 0) {
pr_debug("%s: no update irq?\n", pdev->name);
return -ENOENT;
}
omap_rtc_alarm = platform_get_irq(pdev, 1);
if (omap_rtc_alarm <= 0) {
pr_debug("%s: no alarm irq?\n", pdev->name);
return -ENOENT;
}
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
pr_debug("%s: RTC resource data missing\n", pdev->name);
return -ENOENT;
}
mem = request_mem_region(res->start, resource_size(res), pdev->name);
if (!mem) {
pr_debug("%s: RTC registers at %08x are not free\n",
pdev->name, res->start);
return -EBUSY;
}
rtc_base = ioremap(res->start, resource_size(res));
if (!rtc_base) {
pr_debug("%s: RTC registers can't be mapped\n", pdev->name);
goto fail;
}
rtc = rtc_device_register(pdev->name, &pdev->dev,
&omap_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc)) {
pr_debug("%s: can't register RTC device, err %ld\n",
pdev->name, PTR_ERR(rtc));
goto fail0;
}
platform_set_drvdata(pdev, rtc);
dev_set_drvdata(&rtc->dev, mem);
/* clear pending irqs, and set 1/second periodic,
* which we'll use instead of update irqs
*/
rtc_write(0, OMAP_RTC_INTERRUPTS_REG);
/* clear old status */
reg = rtc_read(OMAP_RTC_STATUS_REG);
if (reg & (u8) OMAP_RTC_STATUS_POWER_UP) {
pr_info("%s: RTC power up reset detected\n",
pdev->name);
rtc_write(OMAP_RTC_STATUS_POWER_UP, OMAP_RTC_STATUS_REG);
}
if (reg & (u8) OMAP_RTC_STATUS_ALARM)
rtc_write(OMAP_RTC_STATUS_ALARM, OMAP_RTC_STATUS_REG);
/* handle periodic and alarm irqs */
if (request_irq(omap_rtc_timer, rtc_irq, IRQF_DISABLED,
dev_name(&rtc->dev), rtc)) {
pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n",
pdev->name, omap_rtc_timer);
goto fail1;
}
if ((omap_rtc_timer != omap_rtc_alarm) &&
(request_irq(omap_rtc_alarm, rtc_irq, IRQF_DISABLED,
dev_name(&rtc->dev), rtc))) {
pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n",
pdev->name, omap_rtc_alarm);
goto fail2;
}
/* On boards with split power, RTC_ON_NOFF won't reset the RTC */
reg = rtc_read(OMAP_RTC_CTRL_REG);
if (reg & (u8) OMAP_RTC_CTRL_STOP)
pr_info("%s: already running\n", pdev->name);
/* force to 24 hour mode */
new_ctrl = reg & ~(OMAP_RTC_CTRL_SPLIT|OMAP_RTC_CTRL_AUTO_COMP);
new_ctrl |= OMAP_RTC_CTRL_STOP;
/* BOARD-SPECIFIC CUSTOMIZATION CAN GO HERE:
*
* - Device wake-up capability setting should come through chip
* init logic. OMAP1 boards should initialize the "wakeup capable"
* flag in the platform device if the board is wired right for
* being woken up by RTC alarm. For OMAP-L138, this capability
* is built into the SoC by the "Deep Sleep" capability.
*
* - Boards wired so RTC_ON_nOFF is used as the reset signal,
* rather than nPWRON_RESET, should forcibly enable split
* power mode. (Some chip errata report that RTC_CTRL_SPLIT
* is write-only, and always reads as zero...)
*/
//.........这里部分代码省略.........
开发者ID:119-org,项目名称:hi3518-osdrv,代码行数:101,代码来源:rtc-omap.c
示例19: Clock_initialize
rtems_device_driver Clock_initialize(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *pargp
)
{
unsigned timer_counter_init_value;
unsigned char clock_lsb, clock_msb;
#ifdef BSP_DEBUG
printk("Initializing clock driver in Clock_initialize().\n");
#endif
#ifdef LOAD_RTC_AT_START
/* Initialize clock from on-board real time clock. This breaks the */
/* test code which assumes which assumes the application will do it. */
{
rtems_time_of_day now;
#ifdef BSP_DEBUG
printk("Loading clock from on-board real-time clock.\n");
#endif
init_rtc();
if (rtc_read(&now) >= 0)
rtems_clock_set(&now);
}
#endif
Clock_driver_ticks = 0;
Clock_isrs =
Clock_initial_isr_value =
rtems_configuration_get_microseconds_per_tick() / 1000; /* ticks per clock_isr */
/*
* configure the counter timer ( should be based on microsecs/tick )
* NB. The divisor(Clock_isrs) resolves the is the same number that appears in confdefs.h
* when setting the microseconds_per_tick value.
*/
ClockOff ( &clockIrqData );
timer_counter_init_value = rtems_configuration_get_microseconds_per_tick() / Clock_isrs;
clock_lsb = (unsigned char)timer_counter_init_value;
clock_msb = timer_counter_init_value >> 8;
outport_byte (TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN);
outport_byte (TIMER_CNTR0, clock_lsb ); /* load LSB first */
outport_byte (TIMER_CNTR0, clock_msb ); /* then MSB */
if (!BSP_install_rtems_irq_handler (&clockIrqData)) {
printk("Unable to initialize system clock\n");
rtems_fatal_error_occurred(1);
}
/*
* make major/minor avail to others such as shared memory driver
*/
rtems_clock_major = major;
rtems_clock_minor = minor;
return RTEMS_SUCCESSFUL;
}
开发者ID:FullMentalPanic,项目名称:RTEMS_NEW_TOOL_CHAIN,代码行数:65,代码来源:ckinit.c
示例20: time_get
unsigned char time_get(unsigned char addr) {
rtc_write(addr);
unsigned char ret = rtc_read();
rtc_transm_end();
return ret;
}
开发者ID:dmand,项目名称:rpi-ds1302,代码行数:6,代码来源:python.c
注:本文中的rtc_read函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论