RTC. Improved function rtcConvertDateTimeToStructTm(). Now it can return milliseconds by optional pointer argument.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7819 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
1d8b2028ac
commit
9e9734dac9
|
@ -128,7 +128,8 @@ extern "C" {
|
||||||
void rtcSetCallback(RTCDriver *rtcp, rtccb_t callback);
|
void rtcSetCallback(RTCDriver *rtcp, rtccb_t callback);
|
||||||
#endif
|
#endif
|
||||||
void rtcConvertDateTimeToStructTm(const RTCDateTime *timespec,
|
void rtcConvertDateTimeToStructTm(const RTCDateTime *timespec,
|
||||||
struct tm *timp);
|
struct tm *timp,
|
||||||
|
uint32_t *tv_msec);
|
||||||
void rtcConvertStructTmToDateTime(const struct tm *timp,
|
void rtcConvertStructTmToDateTime(const struct tm *timp,
|
||||||
uint32_t tv_msec,
|
uint32_t tv_msec,
|
||||||
RTCDateTime *timespec);
|
RTCDateTime *timespec);
|
||||||
|
|
|
@ -213,11 +213,13 @@ void rtcSetCallback(RTCDriver *rtcp, rtccb_t callback) {
|
||||||
*
|
*
|
||||||
* @param[in] timespec pointer to a @p RTCDateTime structure
|
* @param[in] timespec pointer to a @p RTCDateTime structure
|
||||||
* @param[out] timp pointer to a broken-down time structure
|
* @param[out] timp pointer to a broken-down time structure
|
||||||
|
* @param[out] tv_msec pointer to milliseconds value or @p NULL
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
void rtcConvertDateTimeToStructTm(const RTCDateTime *timespec,
|
void rtcConvertDateTimeToStructTm(const RTCDateTime *timespec,
|
||||||
struct tm *timp) {
|
struct tm *timp,
|
||||||
|
uint32_t *tv_msec) {
|
||||||
int tmp;
|
int tmp;
|
||||||
|
|
||||||
timp->tm_year = (int)timespec->year + (1980 - 1900);
|
timp->tm_year = (int)timespec->year + (1980 - 1900);
|
||||||
|
@ -231,6 +233,10 @@ void rtcConvertDateTimeToStructTm(const RTCDateTime *timespec,
|
||||||
timp->tm_min = (tmp % 3600) / 60;
|
timp->tm_min = (tmp % 3600) / 60;
|
||||||
tmp -= timp->tm_min * 60;
|
tmp -= timp->tm_min * 60;
|
||||||
timp->tm_hour = tmp / 3600;
|
timp->tm_hour = tmp / 3600;
|
||||||
|
|
||||||
|
if (NULL != tv_msec) {
|
||||||
|
*tv_msec = (uint32_t)timespec->millisecond % 1000;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue