summaryrefslogtreecommitdiffstatshomepage
path: root/tests/pyb/rtc.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/pyb/rtc.py')
-rw-r--r--tests/pyb/rtc.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/tests/pyb/rtc.py b/tests/pyb/rtc.py
index 844526b4b9..41b52f260d 100644
--- a/tests/pyb/rtc.py
+++ b/tests/pyb/rtc.py
@@ -10,10 +10,12 @@ rtc.datetime((2014, 1, 1, 1, 0, 0, 0, 0))
pyb.delay(1002)
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))
@@ -34,10 +36,12 @@ set_and_print((2099, 12, 31, 7, 23, 59, 59, 0))
# save existing calibration value:
cal_tmp = rtc.calibration()
+
def set_and_print_calib(cal):
rtc.calibration(cal)
print(rtc.calibration())
+
set_and_print_calib(512)
set_and_print_calib(511)
set_and_print_calib(345)
@@ -56,12 +60,13 @@ def set_and_print_wakeup(ms):
try:
rtc.wakeup(ms)
wucksel = stm.mem32[stm.RTC + stm.RTC_CR] & 7
- wut = stm.mem32[stm.RTC + stm.RTC_WUTR] & 0xffff
+ wut = stm.mem32[stm.RTC + stm.RTC_WUTR] & 0xFFFF
except ValueError:
wucksel = -1
wut = -1
print((wucksel, wut))
+
set_and_print_wakeup(0)
set_and_print_wakeup(1)
set_and_print_wakeup(4000)
@@ -72,8 +77,8 @@ set_and_print_wakeup(16000)
set_and_print_wakeup(16001)
set_and_print_wakeup(32000)
set_and_print_wakeup(32001)
-set_and_print_wakeup(0x10000*1000)
-set_and_print_wakeup(0x10001*1000)
-set_and_print_wakeup(0x1ffff*1000)
-set_and_print_wakeup(0x20000*1000)
-set_and_print_wakeup(0x20001*1000) # exception
+set_and_print_wakeup(0x10000 * 1000)
+set_and_print_wakeup(0x10001 * 1000)
+set_and_print_wakeup(0x1FFFF * 1000)
+set_and_print_wakeup(0x20000 * 1000)
+set_and_print_wakeup(0x20001 * 1000) # exception