add: weekday support and fix start value of day and month - 1
This commit is contained in:
parent
ef75ad874d
commit
083468240d
@ -5,6 +5,7 @@
|
|||||||
#define SECOND_REGISTER 0x00
|
#define SECOND_REGISTER 0x00
|
||||||
#define MINUTE_REGISTER 0x02
|
#define MINUTE_REGISTER 0x02
|
||||||
#define HOUR_REGISTER 0x04
|
#define HOUR_REGISTER 0x04
|
||||||
|
#define DAY_OF_THE_WEEK_REGISTER 0x06
|
||||||
#define DAY_OF_THE_MONTH_REGISTER 0x07
|
#define DAY_OF_THE_MONTH_REGISTER 0x07
|
||||||
#define MONTH_REGISTER 0x08
|
#define MONTH_REGISTER 0x08
|
||||||
#define YEAR_REGISTER 0x09
|
#define YEAR_REGISTER 0x09
|
||||||
|
@ -38,7 +38,8 @@ struct rtc_date get_date(void)
|
|||||||
rv.minute = read_register(MINUTE_REGISTER);
|
rv.minute = read_register(MINUTE_REGISTER);
|
||||||
rv.hour = read_register(HOUR_REGISTER);
|
rv.hour = read_register(HOUR_REGISTER);
|
||||||
rv.day = read_register(DAY_OF_THE_MONTH_REGISTER);
|
rv.day = read_register(DAY_OF_THE_MONTH_REGISTER);
|
||||||
rv.month = read_register(MONTH_REGISTER);
|
rv.index_of_the_day = read_register(DAY_OF_THE_WEEK_REGISTER) - 1;
|
||||||
|
rv.month = read_register(MONTH_REGISTER) - 1;
|
||||||
rv.year += read_register(YEAR_REGISTER);
|
rv.year += read_register(YEAR_REGISTER);
|
||||||
century = read_register(CENTURY_REGISTER);
|
century = read_register(CENTURY_REGISTER);
|
||||||
|
|
||||||
@ -47,10 +48,11 @@ struct rtc_date get_date(void)
|
|||||||
rv.minute = bcd_mode_to_bin(rv.minute);
|
rv.minute = bcd_mode_to_bin(rv.minute);
|
||||||
rv.hour = bcd_mode_to_bin(rv.hour);
|
rv.hour = bcd_mode_to_bin(rv.hour);
|
||||||
rv.day = bcd_mode_to_bin(rv.day);
|
rv.day = bcd_mode_to_bin(rv.day);
|
||||||
|
rv.index_of_the_day = bcd_mode_to_bin(rv.index_of_the_day);
|
||||||
rv.month = bcd_mode_to_bin(rv.month);
|
rv.month = bcd_mode_to_bin(rv.month);
|
||||||
rv.year = bcd_mode_to_bin(rv.year);
|
rv.year = bcd_mode_to_bin(rv.year);
|
||||||
century = bcd_mode_to_bin(century);
|
century = bcd_mode_to_bin(century);
|
||||||
}
|
}
|
||||||
rv.year += century * 100 - 108; // -108 = bozo offset
|
rv.year += century * 100 - 98; // -108 = bozo offset
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
@ -16,7 +16,15 @@ void date()
|
|||||||
"October",
|
"October",
|
||||||
"November",
|
"November",
|
||||||
"December" };
|
"December" };
|
||||||
|
static const char * week_days[] = {
|
||||||
|
"Sunday",
|
||||||
|
"Monday",
|
||||||
|
"Tuesday",
|
||||||
|
"Wednesday",
|
||||||
|
"Thursday",
|
||||||
|
"Friday",
|
||||||
|
"Saturday" };
|
||||||
struct rtc_date date = get_date();
|
struct rtc_date date = get_date();
|
||||||
|
|
||||||
kprintf(0, "%s. %d %s. %d %d:%d:%d\n", "mer", date.day, months[date.month], date.year, date.hour, date.minute, date.second);
|
kprintf(0, "%s. %d %s. %d %d:%d:%d\n", week_days[date.index_of_the_day], date.day, months[date.month], date.year, date.hour, date.minute, date.second);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user