Example #1
0
void rtca_init(void)
{

    rtca_time.year = COMPILE_YEAR;
    rtca_time.mon = COMPILE_MON;
    rtca_time.day = COMPILE_DAY;
    rtca_time.dow = COMPILE_DOW;
    rtca_time.hour = COMPILE_HOUR;
    rtca_time.min = COMPILE_MIN;
    rtca_time.sec = 59;

    /* Enable calendar mode (date/time registers are automatically reset)
       and enable read ready interrupts
       and set time event interrupts at each minute
       also enable alarm interrupts */
    RTCCTL01 |= RTCMODE | RTCRDYIE | RTCAIE | RTCTEVIE;

    rtca_set_time();

#ifdef CONFIG_RTC_DST
    /* initialize DST module */
    rtc_dst_init();
#endif

}
Example #2
0
void rtc_dst_hourly_update(void)
{
	if (rtca_time.hour == 2) {
		/* time changes always occur at 2AM */
		if (rtc_dst_state == RTC_DST_STATE_ST) {
			if (rtca_time.mon == rtc_dst_dates[0].month && rtca_time.day == rtc_dst_dates[0].day) {
				/* spring forward */
				rtc_dst_state = RTC_DST_STATE_DST;
				rtca_time.hour++;
				rtca_set_time();
			}
		} else {
			/* rtc_dst_state == RTC_DST_STATE_DST */
			if (rtca_time.mon == rtc_dst_dates[1].month && rtca_time.day == rtc_dst_dates[1].day) {
				/* fall back */
				rtc_dst_state = RTC_DST_STATE_ST;
				rtca_time.hour--;
				rtca_set_time();
			}
		}
	}
}
Example #3
0
static void edit_save()
{
	/* Here we return from the edit mode, fill in the new values! */
	rtca_time.sec = 0;
	rtca_set_time();
	rtca_set_date();

	/* turn off only SOME blinking segments */
	display_chars(0, LCD_SEG_L1_3_0, NULL, BLINK_OFF);
	display_chars(0, LCD_SEG_L2_4_0, NULL, BLINK_OFF);
	display_chars(1, LCD_SEG_L1_3_0, NULL, BLINK_OFF);

	/* return to main screen */
	lcd_screen_activate(0);

	/* start the RTC */
	rtca_start();
}