Skip to content

Merge feature-hal-spec-rtc to master #6996

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
eacefa5
Keep RTC API prototypes even when not enabled
c1728p9 Oct 24, 2017
c8b8126
Keep rtc code if low power timer is used
c1728p9 Oct 23, 2017
9a5cd35
Add documentation and test the HAL RTC API
c1728p9 Aug 11, 2017
155dcb6
Turn off RTC until updated
c1728p9 Oct 12, 2017
1d1f55b
Modify rtc_api.h header file - update tests specification.
mprse Nov 2, 2017
58a7acc
Update of RTC HAL API tests.
mprse Nov 2, 2017
93471cd
Add clarification to rtc_free doxygen
bulislaw Nov 23, 2017
5fc8cd2
Enable RTC support for FAMILY_STM32.
mprse Feb 21, 2018
a02fefe
HAL rtc test: check only if rtc_isenabled() returns 1 in case when in…
mprse Feb 21, 2018
ea218c3
HAL rtc test: increase test timeout.
mprse Feb 21, 2018
3dfa8e0
Fix targets.json for ARM_CM3DS_MPS2 and MIMXRT1050_EVK
mprse Mar 6, 2018
30e95ff
tests-mbed_hal-rtc_reset: Add ack from the device after each command …
mprse Mar 7, 2018
855ebce
Disable RTC support for UBLOX_EVK_ODIN_W2.
mprse Mar 7, 2018
2c627ff
Enable RTC support for K64F board.
mprse Mar 1, 2018
1d71757
K64F: adapt RTC drivers to the new standards (free function)
mprse Mar 1, 2018
70ac410
K64F: adapt RTC drivers to the new standards (is_enabled function)
mprse Mar 1, 2018
0df13b4
Implement of RTC feature for Renesas mbed boards
TomoYamanaka Mar 28, 2018
e77578e
Re-implement RTC for Silicon Labs targets
stevew817 Mar 26, 2018
77381f8
Code style fixes requested by @0xc0170
stevew817 Mar 27, 2018
c5e3c91
Remove unused variable and pointless comparison
stevew817 Mar 27, 2018
7105802
Disable platforms not supporting new RTC
bulislaw Apr 19, 2018
9cdcf16
MCUXpresso: Enable RTC support
mmahadevan108 Mar 26, 2018
c14f45d
MCUXpresso: Enable RTC on LPC54114 and LPC546XX
mmahadevan108 Mar 26, 2018
d2f0135
ADI: Re-enable DEVICE_RTC for EV_COG_AD3029LZ and EV_COG_AD4050LZ
May 18, 2018
347644d
Remove trailing spaces of adi_rtc.c
May 18, 2018
bd3f99f
Preserve RTC counter value while re-initialization
May 18, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 144 additions & 0 deletions TESTS/host_tests/rtc_reset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
"""
mbed SDK
Copyright (c) 2017-2017 ARM Limited

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
from __future__ import print_function

from mbed_host_tests import BaseHostTest
from time import sleep


class RtcResetTest(BaseHostTest):
"""This test checks that a device's RTC keeps count through a reset

It does this by setting the RTC's time, triggering a reset,
delaying and then reading the RTC's time again to ensure
that the RTC is still counting.
"""

"""Start of the RTC"""
START_TIME = 50000
START_TIME_TOLERANCE = 10
"""Time to delay after sending reset"""
DELAY_TIME = 5.0
DELAY_TOLERANCE = 1.0
VALUE_PLACEHOLDER = "0"

def setup(self):
"""Register callbacks required for the test"""
self._error = False
generator = self.rtc_reset_test()
generator.next()

def run_gen(key, value, time):
"""Run the generator, and fail testing if the iterator stops"""
if self._error:
return
try:
generator.send((key, value, time))
except StopIteration:
self._error = True

for resp in ("start", "read", "ack"):
self.register_callback(resp, run_gen)

def teardown(self):
"""No work to do here"""
pass

def rtc_reset_test(self):
"""Generator for running the reset test

This function calls yield to wait for the next event from
the device. If the device gives the wrong response, then the
generator terminates by returing which raises a StopIteration
exception and fails the test.
"""

# Wait for start token
key, value, time = yield
if key != "start":
return

# Initialize, and set the time
self.send_kv("init", self.VALUE_PLACEHOLDER)

# Wait for ack from the device
key, value, time = yield
if key != "ack":
return

self.send_kv("write", str(self.START_TIME))

# Wait for ack from the device
key, value, time = yield
if key != "ack":
return

self.send_kv("read", self.VALUE_PLACEHOLDER)
key, value, time = yield
if key != "read":
return
dev_time_start = int(value)

# Unitialize, and reset
self.send_kv("free", self.VALUE_PLACEHOLDER)

# Wait for ack from the device
key, value, time = yield
if key != "ack":
return

self.send_kv("reset", self.VALUE_PLACEHOLDER)

# No ack after reset
sleep(self.DELAY_TIME)

# Restart the test, and send the sync token
self.send_kv("__sync", "00000000-0000-000000000-000000000000")
key, value, time = yield
if key != "start":
return

# Initialize, and read the time
self.send_kv("init", self.VALUE_PLACEHOLDER)

# Wait for ack from the device
key, value, time = yield
if key != "ack":
return

self.send_kv("read", self.VALUE_PLACEHOLDER)
key, value, time = yield
if key != "read":
return
dev_time_end = int(value)

# Check result
elapsed = dev_time_end - dev_time_start
start_time_valid = (self.START_TIME <= dev_time_start <
self.START_TIME + self.START_TIME_TOLERANCE)
elapsed_time_valid = elapsed >= self.DELAY_TIME - self.DELAY_TOLERANCE
passed = start_time_valid and elapsed_time_valid
if not start_time_valid:
self.log("FAIL: Expected start time of %i got %i" %
(self.START_TIME, dev_time_start))
elif not passed:
self.log("FAIL: Delayed for %fs but device "
"reported elapsed time of %fs" %
(self.DELAY_TIME, elapsed))
self.send_kv("exit", "pass" if passed else "fail")
yield # No more events expected

Loading