Move intrinsic RTC implmentation differences to driver files

Some drivers set tm_wday just fine and do not need it coerced to
be correct. Others set tm_yday, so don't overwrite what the driver
sets; just zero it inside if it can't fill the field. Move calls
to set_day_of_week() to the sorts of drivers that presumably
required the hammer (FS#11814) in get_time() where the weekday
isn't locked to the date.

Change-Id: Idd0ded6bfc9d9f48fcc1a6074068164c42fcf24a
This commit is contained in:
Michael Sevakis 2017-01-25 19:32:15 -05:00
parent 783c77531c
commit 58b849c451
15 changed files with 54 additions and 22 deletions

View file

@ -23,6 +23,7 @@
#include "kernel.h"
#include "system.h"
#include "pmu-target.h"
#include "timefuncs.h"
void rtc_init(void)
{
@ -41,10 +42,12 @@ int rtc_read_datetime(struct tm *tm)
tm->tm_sec = buf[0];
tm->tm_min = buf[1];
tm->tm_hour = buf[2];
tm->tm_wday = buf[3];
tm->tm_mday = buf[4];
tm->tm_mon = buf[5] - 1;
tm->tm_year = buf[6] + 100;
tm->tm_yday = 0; /* Not implemented for now */
set_day_of_week(tm);
return 0;
}

View file

@ -23,6 +23,7 @@
#include "kernel.h"
#include "system.h"
#include "pmu-target.h"
#include "timefuncs.h"
void rtc_init(void)
{
@ -41,10 +42,12 @@ int rtc_read_datetime(struct tm *tm)
tm->tm_sec = buf[0];
tm->tm_min = buf[1];
tm->tm_hour = buf[2];
tm->tm_wday = buf[3];
tm->tm_mday = buf[4];
tm->tm_mon = buf[5] - 1;
tm->tm_year = buf[6] + 100;
tm->tm_yday = 0; /* Not implemented for now */
set_day_of_week(tm);
return 0;
}