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

Fix support for NRF52 #442

Merged
merged 12 commits into from
Jul 1, 2024
Merged

Fix support for NRF52 #442

merged 12 commits into from
Jul 1, 2024

Conversation

edwardalee
Copy link
Contributor

@edwardalee edwardalee commented Jun 2, 2024

With the refactoring of platform support, code generation for NRF52 stopped working. This gets it working again, albeit with quite a few limitations. To program an nRF52 board, we suggest starting with the lf-nRF52 repository. The limitations are documented there.

Summary by CodeRabbit

  • Bug Fixes

    • Corrected system name from "Nrf52" to "nRF52" in various configuration files for consistency.
  • Refactor

    • Improved variable declarations and reuse in the scheduling function for better efficiency.
    • Updated interrupt handling and critical section logic to handle nesting correctly.
  • Documentation

    • Updated platform name in documentation comments to "nRF52" for accuracy.
  • Enhancements

    • Added macro platform_define to apply preprocessor definitions based on defined variables.

@lhstrh
Copy link
Member

lhstrh commented Jun 11, 2024

Any particular reason this is still marked as draft?

@edwardalee
Copy link
Contributor Author

It needs to support soft devices before it's ready for prime time. I'm not sure how to specify in the target parameters whether and which soft device you want. And the makefile generation needs to be tuned. We also need to verify that these changes don't break the Zepher support for nRF52.

Copy link
Contributor

coderabbitai bot commented Jun 23, 2024

Walkthrough

The changes focus on improving code efficiency, consistency, and documentation across various files. In lib/schedule.c, variables are better reused to enhance the efficiency of the lf_schedule_trigger function. Various CMakeLists.txt files are updated to correct and consistently use the platform name "nRF52". Additionally, lf_nrf52_support.{h,c} files are refactored for better interrupt handling and clearer documentation. Lastly, a macro is added to platform/impl/CMakeLists.txt for streamlined preprocessor definitions.

Changes

Files Change Summary
lib/schedule.c Introduced external variable declarations for event_t to reuse across switch cases in lf_schedule_trigger.
.../low_level_platform/api/CMakeLists.txt Changed platform name comparison from "Nrf52" to "nRF52" for consistency.
.../low_level_platform/api/platform/lf_nrf52_support.h Updated documentation comments to correct platform name and author tags formatting.
.../low_level_platform/impl/CMakeLists.txt Corrected platform name in conditional statements and error messages, and updated status message.
.../low_level_platform/impl/src/lf_nrf52_support.c Refactored interrupt handling and critical sections, including renaming and changing variable types.
.../platform/impl/CMakeLists.txt Added a macro to apply preprocessor definitions based on defined variables.

Tip

Early access features: enabled

We are currently testing the following features in early access:

  • OpenAI gpt-4o model for code reviews and chat: OpenAI claims that this model is better at understanding and generating code than the previous models. We seek your feedback over the next few weeks before making it generally available.

Note:

  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.
  • Please join our Discord Community to provide feedback and report issues.
  • OSS projects are currently opted into early access features by default.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@edwardalee edwardalee marked this pull request as ready for review June 23, 2024 18:49
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range and nitpick comments (1)
platform/impl/CMakeLists.txt (1)

20-29: Introduced platform_define macro for flexible compile-time configurations.

The new macro platform_define enhances flexibility by allowing compile-time configurations based on defined variables. This approach should simplify the management of platform-specific settings and is a welcome improvement. Ensure that this macro is well-documented to aid future developers in understanding its usage.

Consider adding detailed comments in the CMakeLists.txt file explaining the purpose and usage of the platform_define macro to improve maintainability.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 587a8f9 and 5a19d6f.

Files selected for processing (6)
  • lib/schedule.c (2 hunks)
  • low_level_platform/api/CMakeLists.txt (1 hunks)
  • low_level_platform/api/platform/lf_nrf52_support.h (2 hunks)
  • low_level_platform/impl/CMakeLists.txt (3 hunks)
  • low_level_platform/impl/src/lf_nrf52_support.c (5 hunks)
  • platform/impl/CMakeLists.txt (1 hunks)
Files skipped from review due to trivial changes (2)
  • low_level_platform/api/platform/lf_nrf52_support.h
  • low_level_platform/impl/CMakeLists.txt
Additional comments not posted (3)
low_level_platform/api/CMakeLists.txt (1)

6-6: Standardized platform naming convention.

The change from "Nrf52" to "nRF52" aligns with the standard naming conventions and improves readability. Ensure that all references to the platform name are updated across the entire project to maintain consistency.

low_level_platform/impl/src/lf_nrf52_support.c (1)

Line range hint 76-97: Refactored interrupt handling and critical section management.

The changes in interrupt handling and critical section management, including the renaming of _lf_nested_region to _lf_nested_count, are appropriate and enhance the clarity and correctness of the code. Ensure that these changes are thoroughly tested, especially in scenarios involving nested interrupts and critical sections.

Also applies to: 195-266

lib/schedule.c (1)

Line range hint 237-254: Optimized event scheduling and conflict handling.

The changes to how events are scheduled and conflicts are handled, particularly with the introduction of the dummy and found variables outside the switch block, optimize the performance and maintainability of the code. Ensure that these changes are covered by comprehensive tests to verify their correctness under various scenarios.

@lhstrh
Copy link
Member

lhstrh commented Jun 30, 2024

@edwardalee what should we do with this PR? Include it in 0.8.0 or not?

@edwardalee
Copy link
Contributor Author

edwardalee commented Jul 1, 2024

Yes, let's merge this. It needs an approving review. There is still work to do, but it is now usable. There is a PR in the lf-lang web page to point to this capability.

@edwardalee edwardalee enabled auto-merge July 1, 2024 09:50
@edwardalee edwardalee added this pull request to the merge queue Jul 1, 2024
Merged via the queue into main with commit 4f8ea7d Jul 1, 2024
29 checks passed
@cmnrd cmnrd deleted the nrf52-fixes branch July 1, 2024 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants