本文整理汇总了C++中rtc_init函数的典型用法代码示例。如果您正苦于以下问题:C++ rtc_init函数的具体用法?C++ rtc_init怎么用?C++ rtc_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rtc_init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pch_rtc_init
static void pch_rtc_init(pci_dev_t dev)
{
int rtc_failed;
u8 reg8;
reg8 = pci_read_config8(dev, GEN_PMCON_3);
rtc_failed = reg8 & RTC_BATTERY_DEAD;
if (rtc_failed) {
reg8 &= ~RTC_BATTERY_DEAD;
pci_write_config8(dev, GEN_PMCON_3, reg8);
}
debug("rtc_failed = 0x%x\n", rtc_failed);
#if CONFIG_HAVE_ACPI_RESUME
/* Avoid clearing pending interrupts and resetting the RTC control
* register in the resume path because the Linux kernel relies on
* this to know if it should restart the RTC timerqueue if the wake
* was due to the RTC alarm.
*/
if (acpi_get_slp_type() == 3)
return;
#endif
/* TODO: Handle power failure */
if (rtc_failed)
printf("RTC power failed\n");
rtc_init();
}
示例2: init
static void init(void) {
usart1_init(115200, buf_in, ARR_LEN(buf_in), buf_out, ARR_LEN(buf_out));
rtc_init();
sei();
puts_P(PSTR("Init complete\n\n"));
}
示例3: rtc_get
/* Read the time from the RTC_STAT. time_in_seconds is seconds since Jan 1970 */
int rtc_get(struct rtc_time *tmp)
{
uint32_t cur_rtc_stat;
int time_in_sec;
int tm_sec, tm_min, tm_hr, tm_day;
pr_stamp();
if (tmp == NULL) {
puts("Error getting the date/time\n");
return -1;
}
rtc_init();
wait_for_complete();
/* Read the RTC_STAT register */
cur_rtc_stat = bfin_read_RTC_STAT();
/* Convert our encoded format into actual time values */
tm_sec = (cur_rtc_stat & RTC_SEC) >> RTC_SEC_P;
tm_min = (cur_rtc_stat & RTC_MIN) >> RTC_MIN_P;
tm_hr = (cur_rtc_stat & RTC_HR ) >> RTC_HR_P;
tm_day = (cur_rtc_stat & RTC_DAY) >> RTC_DAY_P;
/* Calculate the total number of seconds since epoch */
time_in_sec = (tm_sec) + MIN_TO_SECS(tm_min) + HRS_TO_SECS(tm_hr) + DAYS_TO_SECS(tm_day);
to_tm(time_in_sec, tmp);
return 0;
}
示例4: main
int main(void)
{
#ifdef MODULE_LTC4150
ltc4150_start();
#endif
#ifdef FEATURE_PERIPH_RTC
rtc_init();
#endif
#ifdef MODULE_NETIF
gnrc_netreg_entry_t dump;
dump.pid = gnrc_pktdump_pid;
dump.demux_ctx = GNRC_NETREG_DEMUX_CTX_ALL;
gnrc_netreg_register(GNRC_NETTYPE_UNDEF, &dump);
#endif
(void) puts("Welcome to RIOT!");
char line_buf[SHELL_DEFAULT_BUFSIZE];
shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE);
return 0;
}
示例5: esp_clk_init
/*
* This function is not exposed as an API at this point,
* because FreeRTOS doesn't yet support dynamic changing of
* CPU frequency. Also we need to implement hooks for
* components which want to be notified of CPU frequency
* changes.
*/
void esp_clk_init(void)
{
rtc_config_t cfg = RTC_CONFIG_DEFAULT();
rtc_init(cfg);
rtc_clk_fast_freq_set(RTC_FAST_FREQ_8M);
#ifdef CONFIG_ESP32_RTC_CLOCK_SOURCE_EXTERNAL_CRYSTAL
select_rtc_slow_clk(RTC_SLOW_FREQ_32K_XTAL);
#else
select_rtc_slow_clk(RTC_SLOW_FREQ_RTC);
#endif
uint32_t freq_mhz = CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ;
rtc_cpu_freq_t freq = RTC_CPU_FREQ_80M;
switch(freq_mhz) {
case 240:
freq = RTC_CPU_FREQ_240M;
break;
case 160:
freq = RTC_CPU_FREQ_160M;
break;
default:
freq_mhz = 80;
/* no break */
case 80:
freq = RTC_CPU_FREQ_80M;
break;
}
// Wait for UART TX to finish, otherwise some UART output will be lost
// when switching APB frequency
uart_tx_wait_idle(CONFIG_CONSOLE_UART_NUM);
rtc_clk_cpu_freq_set(freq);
}
示例6: main
int main()
{
InitGPIO();
InitBKP();
Set_System();
Set_USBClock();
USB_Interrupts_Config();
USB_Init();
rtc_init();
/*
RTC_t date;
date.year = 2015;
date.month = 10;
date.mday = 24;
date.hour = 23;
date.min = 20;
date.sec = 0;
rtc_settime(&date);
*/
// Start Task //
xTaskCreate(vLcdTask, "vLcdTask", configMINIMAL_STACK_SIZE * 1, NULL, tskIDLE_PRIORITY + 1, &xHandleLcdTask);
xTaskCreate(vDebugTask, "vDebugTask", configMINIMAL_STACK_SIZE * 1, NULL, tskIDLE_PRIORITY + 1, &xHandleDebugTask);
// Start scheduler //
osKernelStart(NULL, NULL);
}
示例7: rtc_write
void rtc_write(time_t t)
{
if (! rtc_inited) {
rtc_init();
}
// Convert timestamp to struct tm
struct tm *timeinfo = localtime(&t);
S_RTC_TIME_DATA_T rtc_datetime;
// Convert S_RTC_TIME_DATA_T to struct tm
rtc_datetime.u32Year = timeinfo->tm_year + YEAR0;
rtc_datetime.u32Month = timeinfo->tm_mon + 1;
rtc_datetime.u32Day = timeinfo->tm_mday;
rtc_datetime.u32DayOfWeek = timeinfo->tm_wday;
rtc_datetime.u32Hour = timeinfo->tm_hour;
rtc_datetime.u32Minute = timeinfo->tm_min;
rtc_datetime.u32Second = timeinfo->tm_sec;
rtc_datetime.u32TimeScale = RTC_CLOCK_24;
// NOTE: Timing issue with write to RTC registers. This delay is empirical, not rational.
RTC_SetDateAndTime(&rtc_datetime);
//nu_nop(6000);
wait_us(100);
}
示例8: main
/**
* MCU: Atmega328
* Fuses: Oscilador interno a 8 Mhz (sin dividir por 8)
* -U lfuse:w:0xe2:m -U hfuse:w:0xd1:m -U efuse:w:0x07:m
*/
int main(void) {
adc_init();
timer0_init(timer0_callback);
i2c_init();
rtc_init(rtc);
rtc_sqw_rate(rtc, 1);
rtc_sqw_enable(rtc);
rtc_clock_start(rtc);
eMBInit(MB_RTU, 0x03, 0, 9600, MB_PAR_NONE);
eMBSetSlaveID(0x3, TRUE, (UCHAR*) "demeter", 8);
eMBEnable();
blinkenlight(5, 100);
parameters_init();
ports_init();
f_mount(&fs, "", 0);
update_log_filename();
while (1) {
eMBPoll();
update_state();
_delay_ms(100);
}
return (0);
}
示例9: rtc_read
time_t rtc_read(void)
{
// NOTE: After boot, RTC time registers are not synced immediately, about 1 sec latency.
// RTC time got (through RTC_GetDateAndTime()) in this sec would be last-synced and incorrect.
// NUC472/M453: Known issue
// M487: Fixed
if (! rtc_isenabled()) {
rtc_init();
}
S_RTC_TIME_DATA_T rtc_datetime;
RTC_GetDateAndTime(&rtc_datetime);
struct tm timeinfo;
// Convert struct tm to S_RTC_TIME_DATA_T
timeinfo.tm_year = rtc_datetime.u32Year - YEAR0;
timeinfo.tm_mon = rtc_datetime.u32Month - 1;
timeinfo.tm_mday = rtc_datetime.u32Day;
timeinfo.tm_wday = rtc_datetime.u32DayOfWeek;
timeinfo.tm_hour = rtc_datetime.u32Hour;
if (rtc_datetime.u32TimeScale == RTC_CLOCK_12 && rtc_datetime.u32AmPm == RTC_PM) {
timeinfo.tm_hour += 12;
}
timeinfo.tm_min = rtc_datetime.u32Minute;
timeinfo.tm_sec = rtc_datetime.u32Second;
// Convert to timestamp
time_t t;
if (_rtc_maketime(&timeinfo, &t, RTC_FULL_LEAP_YEAR_SUPPORT) == false) {
return 0;
}
return t;
}
示例10: rtc_read
time_t rtc_read(void)
{
if (! rtc_inited) {
rtc_init();
}
S_RTC_TIME_DATA_T rtc_datetime;
RTC_GetDateAndTime(&rtc_datetime);
struct tm timeinfo;
// Convert struct tm to S_RTC_TIME_DATA_T
timeinfo.tm_year = rtc_datetime.u32Year - YEAR0;
timeinfo.tm_mon = rtc_datetime.u32Month - 1;
timeinfo.tm_mday = rtc_datetime.u32Day;
timeinfo.tm_wday = rtc_datetime.u32DayOfWeek;
timeinfo.tm_hour = rtc_datetime.u32Hour;
timeinfo.tm_min = rtc_datetime.u32Minute;
timeinfo.tm_sec = rtc_datetime.u32Second;
// Convert to timestamp
time_t t = mktime(&timeinfo);
return t;
}
示例11: rtc_write
void rtc_write(time_t t)
{
if (! rtc_isenabled()) {
rtc_init();
}
// Convert timestamp to struct tm
struct tm timeinfo;
if (_rtc_localtime(t, &timeinfo, RTC_FULL_LEAP_YEAR_SUPPORT) == false) {
return;
}
S_RTC_TIME_DATA_T rtc_datetime;
// Convert S_RTC_TIME_DATA_T to struct tm
rtc_datetime.u32Year = timeinfo.tm_year + YEAR0;
rtc_datetime.u32Month = timeinfo.tm_mon + 1;
rtc_datetime.u32Day = timeinfo.tm_mday;
rtc_datetime.u32DayOfWeek = timeinfo.tm_wday;
rtc_datetime.u32Hour = timeinfo.tm_hour;
rtc_datetime.u32Minute = timeinfo.tm_min;
rtc_datetime.u32Second = timeinfo.tm_sec;
rtc_datetime.u32TimeScale = RTC_CLOCK_24;
// NOTE: Timing issue with write to RTC registers. This delay is empirical, not rational.
RTC_SetDateAndTime(&rtc_datetime);
wait_us(100);
}
示例12: WindowGetSuite
CuSuite* WindowGetSuite(void)
{
CuSuite* suite = CuSuiteNew("ui");
rtc_init();
memlcd_DriverInit();
GrContextInit(&context, &g_memlcd_Driver);
window_init(0);
status_process(EVENT_WINDOW_CREATED, 0, NULL);
SUITE_ADD_TEST(suite, TestScriptEngine);
SUITE_ADD_TEST(suite, TestTriagle);
SUITE_ADD_TEST(suite, TestWideFont);
SUITE_ADD_TEST(suite, TestSportWatch);
SUITE_ADD_TEST(suite, TestTestButton);
SUITE_ADD_TEST(suite, TestTestLight);
SUITE_ADD_TEST(suite, TestTestLcd);
SUITE_ADD_TEST(suite, TestPhoneScreen);
SUITE_ADD_TEST(suite, TestNotification);
SUITE_ADD_TEST(suite, TestControl);
SUITE_ADD_TEST(suite, TestWelcome);
SUITE_ADD_TEST(suite, TestBtConfig);
SUITE_ADD_TEST(suite, TestFontConfig);
SUITE_ADD_TEST(suite, TestSleep);
SUITE_ADD_TEST(suite, TestWindows);
SUITE_ADD_TEST(suite, SimluateRun);
return suite;
}
示例13: kmain
kmain() {
terminal_init();
setup_IDT_entry (&idt[0x08], 0x08, (dword)&_int_08_hand, ACS_INT, 0);
setup_IDT_entry (&idt[0x09], 0x08, (dword)&_int_09_hand, ACS_INT, 0);
setup_IDT_entry (&idt[0x74], 0x08, (dword)&_int_74_hand, ACS_INT, 0);
setup_IDT_entry (&idt[0x80], 0x08, (dword)&_int_80_hand, ACS_INT, 0);
/* IDTR Setting */
idtr.base = 0;
idtr.base +=(dword) &idt;
idtr.limit = sizeof(idt)-1;
_lidt(&idtr);
/* Interrupt unmasking */
_cli();
_maskPIC1(0xF8); /*0XF8*/
_maskPIC2(0xEF); /*0XEF*/
_sti();
video_init();
timertick_init();
rtc_init();
mouse_init();
shell_run();
}
示例14: rtc_get
int
rtc_get(struct rtc_time *tmp)
{
int rel = 0;
struct ds1302_st bbclk;
if(!ds1302_initted) rtc_init();
read_ser_drv(0xbe,(unsigned char *)&bbclk, 8); /* read burst */
if (bbclk.CH) {
printf("ds1302: rtc_get: Clock was halted, clock probably "
"corrupt\n");
rel = -1;
}
tmp->tm_sec=10*bbclk.sec10+bbclk.sec;
tmp->tm_min=10*bbclk.min10+bbclk.min;
tmp->tm_hour=10*bbclk.hr10+bbclk.hr;
tmp->tm_wday=bbclk.day;
tmp->tm_mday=10*bbclk.date10+bbclk.date;
tmp->tm_mon=10*bbclk.month10+bbclk.month;
tmp->tm_year=10*bbclk.year10+bbclk.year + 1900;
tmp->tm_yday = 0;
tmp->tm_isdst= 0;
DPRINTF("Get DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n",
tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
tmp->tm_hour, tmp->tm_min, tmp->tm_sec );
return rel;
}
示例15: setupHardware
static int setupHardware( void )
{
// When using the JTAG debugger the hardware is not always initialised to
// the correct default state. This line just ensures that this does not
// cause all interrupts to be masked at the start.
AT91C_BASE_AIC->AIC_EOICR = 0;
// Enable the peripheral clock.
AT91F_PMC_EnablePeriphClock( AT91C_BASE_PMC, (1 << AT91C_ID_PIOA) | //Enable Clock for PIO
(1 << AT91C_ID_IRQ0) | //Enable Clock for IRQ0
(1 << AT91C_ID_PWMC) | //Enable Clock for the PWM controller
(1 << AT91C_ID_US0) | //USART0
(1 << AT91C_ID_US1) //USART1
);
// Enable reset-button
AT91F_RSTSetMode( AT91C_BASE_RSTC , AT91C_RSTC_URSTEN );
if (!initUsart()) return 0;
if (!vInitUSBInterface()) return 0;
init_serial();
rtc_init();
InitLoggerHardware();
return 1;
}