[riot-notifications] [RIOT-OS/RIOT] periph/rtc: normalize struct tm before usage (#11413)

benpicco notifications at github.com
Wed Apr 17 19:09:51 CEST 2019

### Contribution description
A naive implementation may set a RTC alarm in 30s by calling

	struct tm now;
	now.tm_sec += 30;
	rtc_set_alarm(&now, _cb, NULL);

This works for RTC implementations that use a RTT internally and call
mktime() to convert the struct tm to a unix timestamp, as mktime() will
normalize the struct in the process.

Always call mktime() even when the RTC uses separate registers for time / date
components to ensure it is normalized.

This also modifies tests/periph_rtc to exercise this case.

### Testing procedure
Run `tests/periph_rtc` on a board with RTC.
4 `Alarm!`s should be triggered.

You can view, comment on, or merge this pull request online at:


-- Commit Summary --

  * periph/rtc: normalize struct tm before usage

-- File Changes --

    M cpu/cc430/periph/rtc.c (6)
    M cpu/lpc2387/periph/rtc.c (6)
    M cpu/sam0_common/periph/rtc.c (6)
    M cpu/stm32_common/periph/rtc.c (7)
    M tests/periph_rtc/main.c (5)

-- Patch Links --


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190417/4d32c290/attachment.html>

More information about the notifications mailing list