Esempio n. 1
0
void rtca_set_time()
{
	/* Stop RTC timekeeping for a while */
	rtca_stop();

	/* update RTC registers */
	RTCSEC = rtca_time.sec;
	RTCMIN = rtca_time.min;
	RTCHOUR = rtca_time.hour;

	/* Resume RTC time keeping */
	rtca_start();
}
Esempio n. 2
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();
}
Esempio n. 3
0
void rtca_set_time()
{
    /* Stop RTC timekeeping for a while */
    rtca_stop();

    /* update RTC registers */
    RTCSEC = rtca_time.sec;
    RTCMIN = rtca_time.min;
    RTCHOUR = rtca_time.hour;
    RTCDAY = rtca_time.day;
    RTCDOW = rtca_time.dow;
    RTCMON = rtca_time.mon;
    RTCYEARL = rtca_time.year & 0xff;
    RTCYEARH = rtca_time.year >> 8;

    /* Resume RTC time keeping */
    rtca_start();
}
Esempio n. 4
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;

#ifdef CONFIG_RTC_IRQ
	/* 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;

	RTCSEC = rtca_time.sec;
	RTCMIN = rtca_time.min;
	RTCHOUR = rtca_time.hour;
	RTCDAY = rtca_time.day;
	RTCDOW = rtca_time.dow;
	RTCMON = rtca_time.mon;
	RTCYEARL = rtca_time.year & 0xff;
	RTCYEARH = rtca_time.year >> 8;

	/* Enable the RTC */
	rtca_start();

	/* Enable minutes interrupts */
	RTCCTL01 |= RTCTEVIE;
#endif

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

}
Esempio n. 5
0
void rtca_set_date()
{
	/* Stop RTC timekeeping for a while */
	rtca_stop();

	rtca_update_dow();

	/* update RTC registers and local cache */
	RTCDAY = rtca_time.day;
	RTCDOW = rtca_time.dow;
	RTCMON = rtca_time.mon;
	RTCYEARL = rtca_time.year & 0xff;
	RTCYEARH = rtca_time.year >> 8;

	/* Resume RTC time keeping */
	rtca_start();

#ifdef CONFIG_RTC_DST
	/* calculate new DST switch dates */
	rtc_dst_calculate_dates(rtca_time.year, rtca_time.mon, rtca_time.day, rtca_time.hour);
#endif
}
Esempio n. 6
0
void rtca_set_date()
{
	uint8_t dow;

	/* Stop RTC timekeeping for a while */
	rtca_stop();

	dow = LEAPS_SINCE_YEAR(rtca_time.year);

	if ((29 == rtca_get_max_days(2, rtca_time.year)) && (rtca_time.mon < 3))
		dow--; /* if this is a leap year but before February 29 */

	/* add day of current month */
	dow += rtca_time.day;

	/* add this month's dow value */
	switch (rtca_time.mon) {
	case 5:
		dow += 1;
		break;

	case 8:
		dow += 2;
		break;

	case 2:
	case 3:
	case 11:
		dow += 3;
		break;

	case 6:
		dow += 4;
		break;

	case 9:
	case 12:
		dow += 5;
		break;

	case 4:
	case 7:
		dow += 6;
		break;
	}

	dow = dow % 7;

	/* update RTC registers and local cache */
	RTCDAY = rtca_time.day;
	RTCDOW = (rtca_time.dow = dow);
	RTCMON = rtca_time.mon;
	RTCYEARL = rtca_time.year & 0xff;
	RTCYEARH = rtca_time.year >> 8;

	/* Resume RTC time keeping */
	rtca_start();

#ifdef CONFIG_RTC_DST
	/* calculate new DST switch dates */
	rtc_dst_calculate_dates(rtca_time.year, rtca_time.mon, rtca_time.day, rtca_time.hour);
#endif
}