Skip to content

Add RTC Support: No-OS API, Platform Ops, MAX32690 Driver & Example #2657

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

frmanabat
Copy link

@frmanabat frmanabat commented Jun 30, 2025

Pull Request Description

This pull request introduces RTC (Real-Time Clock) support into the no-OS framework. The update includes the no-OS API implementation, platform operation hooks, MAX32690-specific RTC driver, and an RTC example to demonstrate usage of RTC alarm and integration.

PR Type

  • Bug fix (change that fixes an issue)
  • New feature (change that adds new functionality)
  • Breaking change (has dependencies in other repos or will cause CI to fail)

PR Checklist

  • I have followed the Coding style guidelines
  • I have complied with the Submission Checklist
  • I have performed a self-review of the changes
  • I have commented my code, at least hard-to-understand parts
  • I have build all projects affected by the changes in this PR
  • I have tested in hardware affected projects, at the relevant boards
  • I have signed off all commits from this PR
  • I have updated the documentation (wiki pages, ReadMe etc), if applies

@CLAassistant
Copy link

CLAassistant commented Jun 30, 2025

CLA assistant check
All committers have signed the CLA.

@jemfgeronimo jemfgeronimo self-requested a review June 30, 2025 09:05
@jemfgeronimo
Copy link
Contributor

/AzurePipelines run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@frmanabat frmanabat force-pushed the dev/no_os_rtc branch 2 times, most recently from e8354f1 to 0ded89f Compare June 30, 2025 09:22
Copy link
Collaborator

@cencarna cencarna left a comment

Choose a reason for hiding this comment

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

Other maxim MCUs also has RTC support. You may also want to add support for those MCUs here.


if (!init_param->platform_ops->init)
return -ENOSYS;
// Initilize SPI descriptor
Copy link
Collaborator

Choose a reason for hiding this comment

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

Spelling. Also, don't use double slashes for comments. Use /* Initialize SPI descriptor */

// Initilize SPI descriptor
ret = init_param->platform_ops->init(device, init_param);
if (ret)
return ret;
Copy link
Collaborator

Choose a reason for hiding this comment

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

newline

Comment on lines 82 to 93
return -ENOSYS;
return device->platform_ops->remove(device);
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto: newline

* @param param - The structure that contains the RTC parameters.
* @return 0 in case of success, -ERROR otherwise.
*/
int32_t no_os_rtc_init(struct no_os_rtc_desc **device,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Some platform APIs use int32_t and some use int. For consistency with recent drivers, return int instead for all APIs.

Copy link
Author

Choose a reason for hiding this comment

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

I retained usage of int32_t since the existing no_os_rtc.h in the main branch uses int32_t. I hope this is okay

return -EINVAL;
if (!device->platform_ops->stop)
return -ENOSYS;
ret = device->platform_ops->stop(device);
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto: newline

// Initialize the RTC
ret = no_os_rtc_init(&rtc_desc, &rtc_ip);
if (ret) {
printf("RTC initialization failed.\n");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use pr_err or pr_info from no_os_print_log. Do for all printf instances.

printf("RTC IRQ controller initialization failed.\n");
return ret;
}
ret = no_os_irq_enable(rtc_irq_desc, 3);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Fix indentation.

if (irq_flag){
no_os_gpio_set_value(led, NO_OS_GPIO_LOW); // Turn on the LED
no_os_mdelay(5000); // Delay for 5 seconds
ret = no_os_irq_register_callback(rtc_irq_desc, 3, &rtc_callback);
Copy link
Collaborator

Choose a reason for hiding this comment

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

why re-register irq callback?

Copy link
Author

Choose a reason for hiding this comment

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

Removed re-registration of callback function as it is unnecessary. Also, I moved the resetting of time count onto from the callback function to the main loop. Thanks for this.

return ret;
}
}
else{
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove braces

// print time
ret = no_os_rtc_get_cnt(rtc_desc, &timer_cnt);
if (ret)
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

inline brace

Copy link
Author

Choose a reason for hiding this comment

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

Fixed by running astyle. Thanks

@frmanabat
Copy link
Author

V1 -> V2

  • Fixed Comments from // to /**/ Format
  • Run astyle script to fix indentation issues and bracing
  • Added appropriate whitespaces
  • Changed printf -> pr_info
  • Removed re-registration of callback function in main loop

@kister-jimenez
Copy link
Collaborator

Can the project be a generic RTC example project with multiple platforms supported instead?

@kister-jimenez
Copy link
Collaborator

/AzurePipelines run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@frmanabat
Copy link
Author

frmanabat commented Jul 1, 2025

Can the project be a generic RTC example project with multiple platforms supported instead?

I believe that’s definitely feasible. I recently reviewed the RTC Alarm example in the STM32 IDE, and its structure closely aligns with this example project. Implementing CFLAGS in this example project will conveniently help it handle multiple platforms.

However, I’ve noticed that platform drivers for RTC are currently unavailable for the other target platforms, which may require additional effort to implement.

As for other Maxim MCUs, adding support for RTC should be relatively straightforward, considering the API naming conventions are quite similar. Ultimately, it will come down to testing on the actual hardware to ensure everything functions as expected.

Thanks!

@frmanabat frmanabat changed the title Initial Commit Add no_os_rtc.c, platform ops for no_os_rtc.h, max32690 platform driver for rtc, and rtc example Jul 1, 2025
@frmanabat frmanabat changed the title Add no_os_rtc.c, platform ops for no_os_rtc.h, max32690 platform driver for rtc, and rtc example Add RTC Support: Core API, Platform Ops, MAX32690 Driver & Example Jul 1, 2025
@frmanabat frmanabat changed the title Add RTC Support: Core API, Platform Ops, MAX32690 Driver & Example Add RTC Support: No-OS API, Platform Ops, MAX32690 Driver & Example Jul 1, 2025
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.

5 participants