diff options
| author | Damien George | 2014-05-10 11:56:58 +0100 |
|---|---|---|
| committer | Damien George | 2014-05-10 11:56:58 +0100 |
| commit | 04b7cc4df0a4fe7a6d5ec1e756baac2424b26922 (patch) | |
| tree | 2e40ec86d09d94acd940be0472311e466b726c24 /tests/pyb | |
| parent | c17fd70de93202a97d1af5b48b7db9415951b5a1 (diff) | |
stmhal: Fix setting of RTC: was BCD now BIN encoded.
Addresses issue #592.
Diffstat (limited to 'tests/pyb')
| -rw-r--r-- | tests/pyb/rtc.py | 22 | ||||
| -rw-r--r-- | tests/pyb/rtc.py.exp | 14 |
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/pyb/rtc.py b/tests/pyb/rtc.py index 853aa7957..219d0791a 100644 --- a/tests/pyb/rtc.py +++ b/tests/pyb/rtc.py @@ -3,6 +3,28 @@ from pyb import RTC rtc = RTC() print(rtc) + +# make sure that 1 second passes correctly rtc.datetime((2014, 1, 1, 1, 0, 0, 0, 0)) pyb.delay(1000) print(rtc.datetime()[:7]) + +def set_and_print(datetime): + rtc.datetime(datetime) + print(rtc.datetime()[:7]) + +# make sure that setting works correctly +set_and_print((2000, 1, 1, 1, 0, 0, 0, 0)) +set_and_print((2000, 1, 31, 1, 0, 0, 0, 0)) +set_and_print((2000, 12, 31, 1, 0, 0, 0, 0)) +set_and_print((2016, 12, 31, 1, 0, 0, 0, 0)) +set_and_print((2016, 12, 31, 7, 0, 0, 0, 0)) +set_and_print((2016, 12, 31, 7, 1, 0, 0, 0)) +set_and_print((2016, 12, 31, 7, 12, 0, 0, 0)) +set_and_print((2016, 12, 31, 7, 13, 0, 0, 0)) +set_and_print((2016, 12, 31, 7, 23, 0, 0, 0)) +set_and_print((2016, 12, 31, 7, 23, 1, 0, 0)) +set_and_print((2016, 12, 31, 7, 23, 59, 0, 0)) +set_and_print((2016, 12, 31, 7, 23, 59, 1, 0)) +set_and_print((2016, 12, 31, 7, 23, 59, 59, 0)) +set_and_print((2099, 12, 31, 7, 23, 59, 59, 0)) diff --git a/tests/pyb/rtc.py.exp b/tests/pyb/rtc.py.exp index d1ea2d959..43ea70d95 100644 --- a/tests/pyb/rtc.py.exp +++ b/tests/pyb/rtc.py.exp @@ -1,2 +1,16 @@ <RTC> (2014, 1, 1, 1, 0, 0, 1) +(2000, 1, 1, 1, 0, 0, 0) +(2000, 1, 31, 1, 0, 0, 0) +(2000, 12, 31, 1, 0, 0, 0) +(2016, 12, 31, 1, 0, 0, 0) +(2016, 12, 31, 7, 0, 0, 0) +(2016, 12, 31, 7, 1, 0, 0) +(2016, 12, 31, 7, 12, 0, 0) +(2016, 12, 31, 7, 13, 0, 0) +(2016, 12, 31, 7, 23, 0, 0) +(2016, 12, 31, 7, 23, 1, 0) +(2016, 12, 31, 7, 23, 59, 0) +(2016, 12, 31, 7, 23, 59, 1) +(2016, 12, 31, 7, 23, 59, 59) +(2099, 12, 31, 7, 23, 59, 59) |
