Skip to content
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

include/drivers: Add RTC support #52618

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
7 changes: 7 additions & 0 deletions boards/posix/native_posix/native_posix.dts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
spi-0 = &spi0;
led0 = &led0;
kscan0 = &sdl_kscan;
rtc = &rtc;
};

leds {
Expand Down Expand Up @@ -200,4 +201,10 @@
sample-point = <875>;
bus-speed = <125000>;
};

rtc: rtc {
status = "okay";
compatible = "zephyr,rtc-emul";
alarms-count = <2>;
};
};
50 changes: 49 additions & 1 deletion doc/hardware/peripherals/rtc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,52 @@ API Reference
RTC device driver test suite
****************************

See :ref:`rtc_api_test`
The test suite validates the behavior of the RTC device driver. It
is designed to be portable between boards. It uses the device tree
alias ``rtc`` to designate the RTC device to test.

This test suite tests the following:

* Setting and getting the time.
* RTC Time incrementing correctly.
* Alarms if supported by hardware, with and without callback enabled
* Calibration if supported by hardware.

The calibration test tests a range of values which are printed to the
console to be manually compared. The user must review the set and
gotten values to ensure they are valid.

By default, only the mandatory Setting and getting time is enabled
for testing. To test the optional alarms, update event callback
and clock calibration, these must be enabled by selecting
``CONFIG_RTC_ALARM``, ``CONFIG_RTC_UPDATE`` and
``CONFIG_RTC_CALIBRATION``.
Comment on lines +84 to +85
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As before, use

:kconfig:option:`<name>`

syntax


To build the test application with default settings for a board which
contains the device tree alias ``rtc``, the following command can be used
for reference:

::
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like these parts should be using .. code-block:: bash ?


$ west build -p -b <your board> zephyr/tests/drivers/rtc/rtc_api/

To build the test with additional RTC features enabled, use menuconfig
to enable the additional features. The following command can be used
for reference:

::

$ west build -p -b <your board> -t menuconfig zephyr/tests/drivers/rtc/rtc_api/

Then build the test application using the following command

::

$ west build

To run the test suite, flash and run the application on your board, the output will
be printed to the console.

.. note::

The tests take up to 30 seconds each if they are testing real hardware.
1 change: 0 additions & 1 deletion drivers/rtc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ zephyr_library()

zephyr_library_sources_ifdef(CONFIG_USERSPACE rtc_handlers.c)
zephyr_library_sources_ifdef(CONFIG_RTC_EMUL rtc_emul.c)
bjarki-andreasen marked this conversation as resolved.
Show resolved Hide resolved

2 changes: 2 additions & 0 deletions drivers/rtc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ config RTC_CALIBRATION
This is an option which enables driver support for RTC clock
calibration.

source "drivers/rtc/Kconfig.emul"

endif # RTC
9 changes: 9 additions & 0 deletions drivers/rtc/Kconfig.emul
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2022 Bjarki Arge Andreasen
# SPDX-License-Identifier: Apache-2.0

config RTC_EMUL
bool "Emulated RTC driver"
default y
depends on DT_HAS_ZEPHYR_RTC_EMUL_ENABLED
help
Enable emulated Real-Time Clock (RTC) driver.
Loading