Add RTC module to ports/analog for MAX32690_apard#10592
Merged
tannewt merged 1 commit intoadafruit:mainfrom Aug 28, 2025
Merged
Add RTC module to ports/analog for MAX32690_apard#10592tannewt merged 1 commit intoadafruit:mainfrom
tannewt merged 1 commit intoadafruit:mainfrom
Conversation
I added a port-specific module, RTC to ports/analog. Now the analog port is capable of
handling `rtc.set_time_source()`, `rtc.RTC()` and `r.datetime()`. Note that the RTC
calibration functions are not implemented and is planned for near future.
The implementation in the RTC module also enables two functions in the time module,
which are `time.time()` and `time.localtime()`.
The following example prints the current time every second:
import time
import rtc
r = rtc.RTC)
r.datetime = time.struct_Time((2000, 1, 1, 1, 1, 1, 0, -1, -1))
while(True):
current_time = r.datetime
print(current_time)
time.sleep(1)
Files I modified:
* ports/analog/common-hal/rtc/RTC.c
* ports/analog/common-hal/rtc/RTC.h
* ports/analog/common-hal/rtc/__init__.c
* ports/analog/mpconfigport.mk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
I added a port-specific module, RTC to ports/analog. Now the analog port can handle
rtc.set_time_source(),rtc.RTC()andr.datetime(). Note that the RTC calibration functions (common_hal_rtc_get_calibration()andcommon_hal_rtc_set_calibration()) are not implemented and are planned for the near future.The implementation in the RTC module also enables two functions in the time module, which are
time.time()andtime.localtime().The following example prints the current time once per second:
The expected output is:
The following example call functions from the time module that rely on the RTC module. Successful execution confirms that the newly integrated RTC module enables these related functions in the time module.
An example of the expected output is:
Testing
After I finished implementing the module, I built and flashed the project in the
ports/analogdirectory using OpenOCD with a J-Link device. After flashingfirmware.elfto an AD-APARD32690-SL, I ran the code snippets in both code.py and REPL and received expected results.