Skip to content

Add RTC HAL page to PG #242

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

Merged
merged 4 commits into from
Sep 15, 2017
Merged
Changes from 3 commits
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
40 changes: 40 additions & 0 deletions docs/contributing/rtc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## RTC HAL API

The RTC HAL API provides a low-level interface to the Real Time Counter (RTC) of a target.

### Assumptions

#### Defined behavior

- The function `rtc_init` is safe to call repeatedly.
- RTC accuracy is at least 10%.
- `Init`/`free` doesn't stop RTC from counting.
- Software reset doesn't stop RTC from counting.
- Sleep modes don't stop RTC from counting.
- Shutdown mode doesn't stop RTC from counting.

#### Undefined behavior

- Calling any function other than `rtc_init` before the initialization of the RTC.

#### Potential bugs

- Incorrect overflow handling.
- Glitches due to ripple counter.

### Implementing the RTC API

RTC HAL API is in [hal/rtc_api.h](/docs/v5.4/mbed-os-api-doxy/rtc__api_8h_source.html). You need to implement the following functions to support RTC:

To enable sleep support in Mbed OS, you need to add the `RTC` label in the `device_has` option of the target's section in the `targets.json` file.

### Testing

The [RTC HAL API test suite]() validates:
Copy link
Contributor

Choose a reason for hiding this comment

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

Query: Where should this link?

Copy link
Contributor

Choose a reason for hiding this comment

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

@0xc0170 Can you tell me where this should go?

Copy link
Contributor

Choose a reason for hiding this comment

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

@c1728p9 Do you know where this link should go?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is still under review here:
ARMmbed/mbed-os#5008


- `rtc_init` is safe to call repeatedly - Verified by test `rtc_init_test`.
- `Init`/`free` doesn't stop RTC from counting - Verified by test `rtc_persist_test`.
- Software reset doesn't stop RTC from counting - Verified by `rtc_reset_test`.
- Sleep modes don't stop RTC from counting - Verified by `rtc_sleep_test`.
- Overflow handling - Verified by `rtc_range_test`.
- No backward glitches - Verified by `rtc_glitch_test`.