-
Notifications
You must be signed in to change notification settings - Fork 78
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
Refactor logic analyzer #167
Conversation
I was thinking about having a separate |
In general, I don't think it's necessary for small projects with few committers to have parallel On the other hand, merging known broken code (which this is) into |
8d93290
to
466d79a
Compare
eef9251
to
33448ed
Compare
33448ed
to
f20242b
Compare
Going to merge this soon (into the new and probably temporary 'develop' branch). Some notes on this change:
|
f20242b
to
f51e650
Compare
@sourcery-ai review |
Reviewer's Guide by SourceryThis pull request refactors the logic analyzer instrument and its underlying hardware drivers (IC, DMA, CN, TMR) to improve modularity, reduce code complexity, and prepare for future development. It introduces new self-contained hardware drivers in Updated class diagram for Logic AnalyzerclassDiagram
class LogicAnalyzer {
-uint16_t* g_buffer
-uint16_t g_buffer_n_items
-uint8_t g_n_channels
-uint8_t g_initial_states
-TMR_Timer g_TIMER
+enum Status LA_capture(uint8_t n_channels, uint16_t events, Edge edge, Channel trigger)
+enum Status LA_fetch(uint16_t** buffer, uint16_t* n_items)
+enum Status LA_stop()
+enum Status LA_get_initial_states(uint8_t* initial_states)
+enum Status LA_cmd_capture(uint8_t** args, uint16_t args_size, uint8_t** rets, uint16_t* rets_size)
+enum Status LA_cmd_fetch(uint8_t** args, uint16_t args_size, uint8_t** rets, uint16_t* rets_size)
+enum Status LA_cmd_stop(uint8_t** args, uint16_t args_size, uint8_t** rets, uint16_t* rets_size)
+enum Status LA_cmd_get_initial_states(uint8_t** args, uint16_t args_size, uint8_t** rets, uint16_t* rets_size)
}
class CN {
+void CN_reset()
+void CN_interrupt_enable(Channel pin, InterruptCallback callback)
}
class IC {
+void IC_reset(Channel channel)
+void IC_start(Channel channel, Edge edge, IC_Timer timer)
+void IC_interrupt_enable(Channel channel, InterruptCallback callback)
+void IC_interrupt_disable(Channel channel)
}
class DMA {
+void DMA_reset(Channel channel)
+void DMA_setup(Channel channel, uint16_t count, size_t address, DMA_Source source)
+void DMA_start(Channel channel)
+void DMA_interrupt_enable(Channel channel, InterruptCallback callback)
}
class TMR {
+void TMR_reset(TMR_Timer timer)
+void TMR_start(TMR_Timer timer)
+void TMR_set_period(TMR_Timer timer, uint16_t period)
}
LogicAnalyzer -- CN
LogicAnalyzer -- IC
LogicAnalyzer -- DMA
LogicAnalyzer -- TMR
note for LogicAnalyzer "Refactored Logic Analyzer instrument"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @bessman - I've reviewed your changes and found some issues that need to be addressed.
Blocking issues:
- Uninitialized 'input' pointer in LA_cmd_capture. (link)
Overall Comments:
- The introduction of the
registers_ng
directory and associated changes looks good, but consider renaming it toregisters
in this PR if the old directory is no longer needed. - The new logic analyzer driver introduces a lot of new types - consider grouping them together in a single header file.
Here's what I looked at during the review
- 🔴 General issues: 1 blocking issue, 2 other issues
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 2 issues found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There are transitive and circular dependencies everywhere. This began with removing src/helpers/interval.*, which is superceded by the new logic analyzer implementation. But the old IC driver transitivelly depended on interval, so it had to go. Then a bunch of things that depended on IC had to go, and so on and so forth. Basically, better to start fresh at this point.
@sourcery-ai review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @bessman - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider adding a high-level overview of the design to the top of each new
.c
file. - It would be helpful to include a diagram of the module dependencies in the documentation.
Here's what I looked at during the review
- 🟡 General issues: 2 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 2 issues found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
@sourcery-ai review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @bessman - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider adding a brief description of the logic analyzer's functionality to the
logic_analyzer.h
file. - The
types.h
file is a good place to define common types, but consider if it should be moved to theregisters_ng
directory.
Here's what I looked at during the review
- 🟡 General issues: 5 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This is the first part of the major refactorization I'm currently working on. It refactors the logic analyzer instrument, as well as the underlying hardware drivers it depends on, including:
This pull request breaks any instrument which depend on an interrupt service routine from any of the above drivers. This is because I'm refactoring the interrupts to be more modular by using callbacks. The broken instruments will be fixed as part of the ongoing refactorization.
The new low-level hardware drivers currently reside in src/registers_ng, to be renamed to src/registers once the refactorization is complete. These drivers are designed to be self-contained, i.e. they have no dependencies on any resources other than themselves. This design aims to solve the current spaghetti-ness of the firmware code, where every module depends on several other modules, often in a transitive or circular manner.
Depends on #165 and #166.
Summary by Sourcery
Refactor the logic analyzer instrument and its underlying hardware drivers to improve modularity and reduce code complexity
New Features:
Enhancements:
Chores: