RTC. Implemented function rtcConvertDateTimeToFAT()
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7436 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
b665c20b66
commit
c145bd903f
|
@ -124,7 +124,7 @@ extern "C" {
|
||||||
#if RTC_SUPPORTS_CALLBACKS
|
#if RTC_SUPPORTS_CALLBACKS
|
||||||
void rtcSetCallback(RTCDriver *rtcp, rtccb_t callback);
|
void rtcSetCallback(RTCDriver *rtcp, rtccb_t callback);
|
||||||
#endif
|
#endif
|
||||||
uint32_t rtcConvertDateTimeToFAT(RTCDateTime *timespec);
|
uint32_t rtcConvertDateTimeToFAT(const RTCDateTime *timespec);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -193,12 +193,26 @@ void rtcSetCallback(RTCDriver *rtcp, rtccb_t callback) {
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
uint32_t rtcConvertDateTimeToFAT(RTCDateTime *timespec) {
|
uint32_t rtcConvertDateTimeToFAT(const RTCDateTime *timespec) {
|
||||||
|
|
||||||
|
uint32_t fattime;
|
||||||
|
uint32_t sec, min, hour, tmp;
|
||||||
|
|
||||||
osalDbgCheck(timespec != NULL);
|
osalDbgCheck(timespec != NULL);
|
||||||
|
|
||||||
/* TODO: Implement.*/
|
tmp = timespec->millisecond / 1000;
|
||||||
return 0;
|
sec = tmp % 60;
|
||||||
|
min = (tmp - sec) % 3600;
|
||||||
|
hour = (tmp - sec - min * 60) / 3600;
|
||||||
|
|
||||||
|
fattime = sec >> 1;
|
||||||
|
fattime |= min << 5;
|
||||||
|
fattime |= hour << 11;
|
||||||
|
fattime |= timespec->day << 16;
|
||||||
|
fattime |= timespec->month << 21;
|
||||||
|
fattime |= timespec->year << 25;
|
||||||
|
|
||||||
|
return fattime;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* HAL_USE_RTC */
|
#endif /* HAL_USE_RTC */
|
||||||
|
|
Loading…
Reference in New Issue