Skip to content

add RTC#60

Open
gkuznik wants to merge 3 commits into
mainfrom
feature/rtc
Open

add RTC#60
gkuznik wants to merge 3 commits into
mainfrom
feature/rtc

Conversation

@gkuznik
Copy link
Copy Markdown
Member

@gkuznik gkuznik commented May 3, 2026

No description provided.

Copilot AI review requested due to automatic review settings May 3, 2026 20:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds RTC support to the kernel and STM32L4 machine layer so the kernel can read/write wall-clock time and persist a small amount of RTC-backed state across resets.

Changes:

  • Add RTC initialization, raw RTC accessors, and backup-register access in the STM32L4 C interface.
  • Expose RTC APIs through the machine abstraction and implement them for native and stub Cortex-M backends.
  • Add kernel-side time helpers plus a new time thread that is started during kernel initialization.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/time.rs Adds kernel RTC helpers, Unix/RTC conversion logic, and the new time thread.
src/lib.rs Starts the new time thread during kernel initialization.
machine/cortex-m/st/stm32l4/interface/export.h Exposes new RTC and backup-register symbols to Rust bindings.
machine/cortex-m/st/stm32l4/interface/clock.c Initializes RTC hardware, selects RTC clock source, and implements RTC read/write helpers.
machine/cortex-m/src/stub.rs Adds stub RTC methods for the test/non-hardware backend.
machine/cortex-m/src/native.rs Wires the new RTC bindings into the native Cortex-M machine implementation.
machine/api/src/lib.rs Extends the machine trait with RTC and backup-register operations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/time.rs Outdated
Comment thread src/time.rs Outdated
Comment thread src/time.rs Outdated
Comment thread machine/cortex-m/st/stm32l4/interface/clock.c
Comment thread machine/cortex-m/st/stm32l4/interface/clock.c Outdated
Comment thread machine/cortex-m/st/stm32l4/interface/clock.c Outdated
Comment thread src/time.rs Outdated
rename functions
unsafe { bindings::monotonic_freq() }
}

fn rtc_raw() -> u64 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If I understand correctly, you assume that every HAL exposes an rtc_raw function that returns a BCD-encoded time. I would not make this the public API. I think it makes more sense to expose POSIX time as universal format and make the conversion HAL/driver defined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants