tests/periph_rtc: test clear alarm
This commit is contained in:
parent
33afc0ddab
commit
e7054b4f53
@ -92,8 +92,30 @@ int main(void)
|
|||||||
/* verify alarm */
|
/* verify alarm */
|
||||||
rtc_get_alarm(&time);
|
rtc_get_alarm(&time);
|
||||||
print_time(" Alarm is set to ", &time);
|
print_time(" Alarm is set to ", &time);
|
||||||
|
|
||||||
|
/* clear alarm */
|
||||||
|
rtc_clear_alarm();
|
||||||
|
rtc_get_time(&time);
|
||||||
|
print_time(" Alarm cleared at ", &time);
|
||||||
|
|
||||||
|
/* verify alarm has been cleared */
|
||||||
|
xtimer_sleep(PERIOD);
|
||||||
|
rtc_get_time(&time);
|
||||||
|
if (mutex_trylock(&rtc_mtx)) {
|
||||||
|
print_time(" Error: Alarm at ", &time);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print_time(" No alarm at ", &time);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set alarm */
|
||||||
|
rtc_get_time(&time);
|
||||||
|
inc_secs(&time, PERIOD);
|
||||||
|
rtc_set_alarm(&time, cb, &rtc_mtx);
|
||||||
|
print_time(" Setting alarm to ", &time);
|
||||||
puts("");
|
puts("");
|
||||||
|
|
||||||
|
/* loop over a few alarm cycles */
|
||||||
while (1) {
|
while (1) {
|
||||||
mutex_lock(&rtc_mtx);
|
mutex_lock(&rtc_mtx);
|
||||||
puts("Alarm!");
|
puts("Alarm!");
|
||||||
|
|||||||
@ -21,13 +21,8 @@ def testfunc(child):
|
|||||||
alarm_count = int(child.match.group(1))
|
alarm_count = int(child.match.group(1))
|
||||||
child.expect(r' Setting clock to ({})'.format(DATE_PATTERN))
|
child.expect(r' Setting clock to ({})'.format(DATE_PATTERN))
|
||||||
clock_set = child.match.group(1)
|
clock_set = child.match.group(1)
|
||||||
if BOARD == 'native':
|
|
||||||
child.expect(r'.*rtc_set_time: not implemented')
|
|
||||||
child.expect(r'Clock value is now ({})'.format(DATE_PATTERN))
|
child.expect(r'Clock value is now ({})'.format(DATE_PATTERN))
|
||||||
clock_value = child.match.group(1)
|
clock_value = child.match.group(1)
|
||||||
if BOARD != 'native':
|
|
||||||
# Set clock is not implemented for native board so no need to compare
|
|
||||||
# clock values
|
|
||||||
assert clock_set == clock_value
|
assert clock_set == clock_value
|
||||||
|
|
||||||
child.expect(r' Setting alarm to ({})'.format(DATE_PATTERN))
|
child.expect(r' Setting alarm to ({})'.format(DATE_PATTERN))
|
||||||
@ -36,6 +31,12 @@ def testfunc(child):
|
|||||||
alarm_value = child.match.group(1)
|
alarm_value = child.match.group(1)
|
||||||
assert alarm_set == alarm_value
|
assert alarm_set == alarm_value
|
||||||
|
|
||||||
|
child.expect(r" Alarm cleared at ({})".format(DATE_PATTERN))
|
||||||
|
child.expect(r" No alarm at ({})".format(DATE_PATTERN))
|
||||||
|
no_alarm_value = child.match.group(1)
|
||||||
|
assert alarm_value == no_alarm_value
|
||||||
|
|
||||||
|
child.expect(r" Setting alarm to ({})".format(DATE_PATTERN))
|
||||||
for _ in range(alarm_count):
|
for _ in range(alarm_count):
|
||||||
child.expect_exact('Alarm!')
|
child.expect_exact('Alarm!')
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user