/** * alarmtimer_get_rtcdev - Return selected rtcdevice * * This function returns the rtc device to use for wakealarms. * If one has not already been chosen, it checks to see if a * functional rtc device is available. */ static struct rtc_device *alarmtimer_get_rtcdev(void) { struct device *dev; char *str; unsigned long flags; struct rtc_device *ret; spin_lock_irqsave(&rtcdev_lock, flags); if (!rtcdev) { /* Find an rtc device and init the rtc_timer */ dev = class_find_device(rtc_class, NULL, &str, has_wakealarm); /* If we have a device then str is valid. See has_wakealarm() */ if (dev) { rtcdev = rtc_class_open(str); /* * Drop the reference we got in class_find_device, * rtc_open takes its own. */ put_device(dev); rtc_timer_init(&rtctimer, NULL, NULL); } } ret = rtcdev; spin_unlock_irqrestore(&rtcdev_lock, flags); return ret; }
/**@brief Function for application main entry. */ int main(void) { #ifdef OSSW_DEBUG init_uart(); #endif spi_init(); ext_ram_init(); init_lcd_with_splash_screen(); accel_init(); // Initialize. timers_init(); rtc_timer_init(); buttons_init(); battery_init(); // Initialize the SoftDevice handler module. SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, NULL); // splash screen nrf_delay_ms(500); fs_init(); config_init(); scr_mngr_init(); vibration_init(); notifications_init(); stopwatch_init(); timer_feature_init(); mlcd_timers_init(); // Enter main loop. for (;;) { if (rtc_should_store_current_time()) { rtc_store_current_time(); } app_sched_execute(); stopwatch_process(); command_process(); watchset_process_async_operation(); scr_mngr_draw_screen(); power_manage(); } }
int main( void ) { lfclk_config(); //RTC1_Init(); rtc_timer_init(); setup(); for (;;) { loop(); } return 0; }
// main program body int main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT board_init(); // init dco and leds uart_init(); // init uart rtc_timer_init(); // init rtc timer ds18b20_sensor_t s[3]; // init ds18b20 sensors ds18b20_init(&s[0],&P2OUT,&P2IN,&P2REN,&P2DIR,0); // sensor 0: PORT2 pin 0 ds18b20_init(&s[1],&P2OUT,&P2IN,&P2REN,&P2DIR,1); // sensor 1: PORT2 pin 1 ds18b20_init(&s[2],&P2OUT,&P2IN,&P2REN,&P2DIR,2); // sensor 2: PORT2 pin 2 prog_init(); pout_init(); // init power output (pump switch) while(1) { int i; for (i=0;i<3;i++) ds18d20_start_conversion(&s[i]); // start conversion __bis_SR_register(CPUOFF + GIE); // enter sleep mode (leave on rtc second event) for (i=0;i<3;i++) { ds18b20_read_conversion(&s[i]); // read data from sensor if (s[i].valid==true) { t_val[i]=s[i].data.temp; // save temperature value t_err[i]=0; // clear error counter } else if (t_err[i]!=0xFFFF) t_err[i]++; // increase error counter } __bis_SR_register(CPUOFF + GIE); // enter sleep mode (leave on rtc second event) if (minute_event) { minute_event=false; if (pauto) pout_set(AUTO); __bis_SR_register(CPUOFF + GIE); // enter sleep mode (leave on rtc second event) } } return -1; }
/* * Initialize the real-time clock device. * In addition, various variables used to support the clock are initialized. */ int rtclock_init(void) { uint64_t cycles; assert(!ml_get_interrupts_enabled()); if (cpu_number() == master_cpu) { assert(tscFreq); rtc_set_timescale(tscFreq); /* * Adjust and set the exported cpu speed. */ cycles = rtc_export_speed(tscFreq); /* * Set min/max to actual. * ACPI may update these later if speed-stepping is detected. */ gPEClockFrequencyInfo.cpu_frequency_min_hz = cycles; gPEClockFrequencyInfo.cpu_frequency_max_hz = cycles; rtc_timer_init(); clock_timebase_init(); ml_init_lock_timeout(); ml_init_delay_spin_threshold(10); } /* Set fixed configuration for lapic timers */ rtc_timer->config(); rtc_timer_start(); return (1); }
static inline void alarmtimer_rtc_timer_init(void) { rtc_timer_init(&rtctimer, NULL, NULL); }
static inline void alarmtimer_rtc_timer_init(void) { mutex_init(&power_on_alarm_lock); rtc_timer_init(&rtctimer, NULL, NULL); }
// main program body int main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT board_init(); // init dco and leds lcm_init(); // lcd rtc_timer_init(); // init 32kHz timer uart_init(); // init uart (communication) //buttons_init(); // buttons dcf77_init(); // dcf77 receiver #if DCF77_DEBUG lcm_goto(0,0); lcm_prints("DCF"); #endif while(1) { __bis_SR_register(CPUOFF + GIE); // enter sleep mode (leave on rtc second event) tstruct tnow; rtc_get_time(&tnow); char tstr[16]; sprint_time(&tnow,tstr); lcm_goto(1,0); lcm_prints(tstr); str_add_lineend(tstr,16); uart_puts(tstr); uint8_t b=get_button(); if (b) { /*lcm_goto(0,3); tstr[0]='0'+b; tstr[1]='\0'; lcm_prints(tstr);*/ if (b==3) // test rtc set function { tnow.second = 0; tnow.minute = 33; tnow.hour = 22; tnow.dayow = 2; rtc_set_time(&tnow); } } #if DCF77_DEBUG // dcf if (symbol_ready) { int ci=0; lcm_goto(0,3); tstr[ci++]=h2c(tunestatus); tstr[ci++]=' '; tstr[ci++]=h2c(last_symbol); tstr[ci++]=' '; tstr[ci++]=h2c((int)last_Q/100%10); tstr[ci++]=h2c((int)last_Q/10%10); tstr[ci++]=h2c((int)last_Q%10); tstr[ci++]=' '; tstr[ci++]=h2c((int)(finetune>>12)); tstr[ci++]=h2c((int)(finetune>>8)&0x0F); tstr[ci++]=h2c((int)(finetune>>4)&0x0F); tstr[ci++]=h2c((int)(finetune&0x0F)); tstr[ci++]='\0'; lcm_prints(tstr); symbol_ready = false; } #endif } return -1; }