[riot-commits] [RIOT-OS/RIOT] fa9e90: periph_common/rtc: add rtc_tm_normalize()

Marian Buschsieweke noreply at github.com
Thu Sep 12 12:47:58 CEST 2019


  Branch: refs/heads/master
  Home:   https://github.com/RIOT-OS/RIOT
  Commit: fa9e9064cf72fb280ae9cf26b86b0be52c50bea1
      https://github.com/RIOT-OS/RIOT/commit/fa9e9064cf72fb280ae9cf26b86b0be52c50bea1
  Author: Benjamin Valentin <benpicco at googlemail.com>
  Date:   2019-09-12 (Thu, 12 Sep 2019)

  Changed paths:
    M drivers/include/periph/rtc.h
    A drivers/periph_common/rtc.c

  Log Message:
  -----------
  periph_common/rtc: add rtc_tm_normalize()


  Commit: 90a8a9666c93cf583d9742afdd4e7546323e025f
      https://github.com/RIOT-OS/RIOT/commit/90a8a9666c93cf583d9742afdd4e7546323e025f
  Author: Benjamin Valentin <benjamin.valentin at ml-pa.com>
  Date:   2019-09-12 (Thu, 12 Sep 2019)

  Changed paths:
    A tests/unittests/tests-rtc/Makefile
    A tests/unittests/tests-rtc/Makefile.include
    A tests/unittests/tests-rtc/tests-rtc.c
    A tests/unittests/tests-rtc/tests-rtc.h

  Log Message:
  -----------
  unittests: add tests for rtc_tm_normalize()


  Commit: b1724a7d1bc6ea355b12df0416c293553a83d643
      https://github.com/RIOT-OS/RIOT/commit/b1724a7d1bc6ea355b12df0416c293553a83d643
  Author: Benjamin Valentin <benjamin.valentin at ml-pa.com>
  Date:   2019-09-12 (Thu, 12 Sep 2019)

  Changed paths:
    M cpu/cc430/periph/rtc.c
    M cpu/lpc2387/periph/rtc.c
    M cpu/sam0_common/periph/rtc.c
    M cpu/stm32_common/periph/rtc.c
    M tests/periph_rtc/main.c

  Log Message:
  -----------
  periph/rtc: normalize struct tm before usage

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

	struct tm now;
	rtc_get_time(&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.

Call rtc_tm_normalize() 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.


  Commit: c2627706348c3a8fecbb99562ade5aad3315486d
      https://github.com/RIOT-OS/RIOT/commit/c2627706348c3a8fecbb99562ade5aad3315486d
  Author: Marian Buschsieweke <maribu at users.noreply.github.com>
  Date:   2019-09-12 (Thu, 12 Sep 2019)

  Changed paths:
    M cpu/cc430/periph/rtc.c
    M cpu/lpc2387/periph/rtc.c
    M cpu/sam0_common/periph/rtc.c
    M cpu/stm32_common/periph/rtc.c
    M drivers/include/periph/rtc.h
    A drivers/periph_common/rtc.c
    M tests/periph_rtc/main.c
    A tests/unittests/tests-rtc/Makefile
    A tests/unittests/tests-rtc/Makefile.include
    A tests/unittests/tests-rtc/tests-rtc.c
    A tests/unittests/tests-rtc/tests-rtc.h

  Log Message:
  -----------
  Merge pull request #11413 from benpicco/rtc_sanitize

periph/rtc: normalize struct tm before usage


Compare: https://github.com/RIOT-OS/RIOT/compare/1887e9d3f4e2...c2627706348c


More information about the commits mailing list