-
Notifications
You must be signed in to change notification settings - Fork 14
stm32l4-multi: pwmbitseq_t refactor #606
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
base: master
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @radekszewczyk01, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request primarily focuses on optimizing embedded system communication and driver efficiency. It introduces a more flexible structure for Pulse Width Modulation (PWM) bit sequences, allowing multiple sequences to be transmitted in a single operation to a multidriver. Concurrently, the UART 16550 driver has been refactored to remove an intermediate software buffer and simplify its interrupt handling mechanism, aiming for a more direct and efficient interaction with the hardware. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request introduces an optimization for PWM bit sequence handling by modifying the pwmbitseq_t structure to support multiple channels in a single message. It also includes a significant refactoring of the uart16550 driver, simplifying its interrupt handling logic. I've found a critical issue in the new PWM handling loop that includes a compile error and a logic bug that could mask errors. I've also noted some newly introduced macros that appear to be unused. Other changes, including style adjustments, seem appropriate.
| for (uint8_t i = 0; i < imsg->pwm_bitseq.count; i++) { | ||
| assert(imsg->bitseqTable[i]); | ||
| err = pwm_setBitSequence(imsg->pwm_bitseq.bitseqTable[i].timer, imsg->pwm_bitseq.bitseqTable[i].chn, imsg->pwm_bitseq.bitseqTable[i].data, | ||
| imsg->pwm_bitseq.bitseqTable[i].nbits, imsg->pwm_bitseq.bitseqTable[i].datasize, imsg->pwm_bitseq.bitseqTable[i].flags); | ||
| } |
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.
This loop has a couple of issues:
- Compile Error: The
asserton line 269 contains a typo (imsg->bitseqTable[i]). The correct member isimsg->pwm_bitseq.bitseqTable. This will prevent the code from compiling. - Error Handling: The
errvariable is overwritten in each iteration. Ifpwm_setBitSequence()fails for any but the last item, the error will be lost, and the operation might be considered successful. The loop should terminate on the first error.
I suggest replacing the loop with a version that corrects the assertion and handles errors properly.
if (imsg->pwm_bitseq.count > 0) {
assert(imsg->pwm_bitseq.bitseqTable != NULL);
for (uint8_t i = 0; i < imsg->pwm_bitseq.count; i++) {
err = pwm_setBitSequence(imsg->pwm_bitseq.bitseqTable[i].timer, imsg->pwm_bitseq.bitseqTable[i].chn, imsg->pwm_bitseq.bitseqTable[i].data,
imsg->pwm_bitseq.bitseqTable[i].nbits, imsg->pwm_bitseq.bitseqTable[i].datasize, imsg->pwm_bitseq.bitseqTable[i].flags);
if (err < 0) {
break;
}
}
}
tty/uart16550/uart16550.h
Outdated
| #define SIZE_SERIALS 2 | ||
| #define SIZE_SERIAL_CHUNK 256 |
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.
nalajcie
left a comment
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.
why there is some revert commit here without any rationale? (unrelated change)
lots of unnecessary reformatting (either make them a separate commit or revert)
Please make a meaningful PR title.
181e794 to
45e5e62
Compare
45e5e62 to
07a4fcf
Compare
JIRA: PP-401
07a4fcf to
d428f04
Compare
Change pwmbitseq_t structure
Description
Change pwmbitseq_t structure in order to optimize communication with multidriver
Motivation and Context
Multidriver required seperate message for each channel, which was inefficient.
Types of changes
How Has This Been Tested?
Checklist:
Special treatment