Skip to content

Perchance We May need Input?#122

Open
XanBu wants to merge 24 commits into
mainfrom
feature/xmb4293/pwm_input_v2
Open

Perchance We May need Input?#122
XanBu wants to merge 24 commits into
mainfrom
feature/xmb4293/pwm_input_v2

Conversation

@XanBu

@XanBu XanBu commented Sep 12, 2025

Copy link
Copy Markdown

Implemented Pulse Width Modulation Input for f302. Tested all pins. I have a file that lists all correct pins and alternate functions specifically for PWM_INPUT, and some reasons why certain ones aren't used but I don't have permission to edit the drive.

@XanBu XanBu requested a review from a team September 12, 2025 00:42

@ActuallyTaylor ActuallyTaylor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks great! Very very solid code.

I only have one suggestion for one of the samples (seems to be a testing change left over).

I also want to note that pieces of this class will need to change with #125, but that can be handled in that PR.

Comment thread samples/pwm/main.cpp Outdated
Comment thread samples/pwm_input/main.cpp Outdated
Comment thread src/core/io/platform/f3xx/PWM_INPUTf3xx.cpp Outdated
Comment thread src/core/io/platform/f3xx/PWMInputf3xx.cpp
XanBu and others added 3 commits October 9, 2025 18:16
Left over testing change

Co-authored-by: Taylor Lineman <taylor.lineman@gmail.com>
Removed extra empty line

Co-authored-by: Taylor Lineman <taylor.lineman@gmail.com>
@XanBu XanBu requested a review from ActuallyTaylor October 9, 2025 22:26

@mjh9585 mjh9585 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Very nice, mainly just a bunch of nit picks. Some of this comments may not apply once the new timers are in, but still things to be aware of. Good work!

Comment thread include/core/io/PWMInput.hpp
Comment thread include/core/io/PWMInput.hpp
Comment thread include/core/io/platform/f3xx/PWMInputf3xx.hpp
Comment thread samples/pwm_input/main.cpp Outdated
Comment thread src/core/io/PWM_INPUT.cpp Outdated

namespace core::io {

PWM_INPUT::PWM_INPUT(Pin pin) { // core::io::Pin pin

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Convert this to an initializer list.

Comment thread src/core/io/platform/f3xx/PWM_INPUTf3xx.cpp Outdated
Comment thread src/core/io/platform/f3xx/PWMInputf3xx.cpp
Comment on lines +231 to +233
TIM_HandleTypeDef* PWM_INPUTf3xx::getHandle() {
return &halTIM;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of making this publicly available, store a pointer to your timer in a file global variable like your activePwmInput var that you could use in your interrupt.

Comment on lines +255 to +257
if (activePwmInput) {
activePwmInput->handleCapture(htim);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To support multiple inputs, you will need a way to look up the class instance from the timer instance. Look at some of the other drivers for an example.

}
}

void PWM_INPUTf3xx::handleCapture(TIM_HandleTypeDef* htim) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Place your IRQ handlers at the top of your file and keep your class member definition together for better readability.

@ActuallyTaylor

Copy link
Copy Markdown
Member

Looks great :) Approved, pending Matts requested changes!

@XanBu XanBu changed the title Perchance We Need Input? Perchance We May need Input? Oct 17, 2025

@ActuallyTaylor ActuallyTaylor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I went back over @mjh9585's suggestions and almost everything seems to be fixed. The only thing I see right now is the multiple input instances problem he brought up.

Comment thread src/core/io/platform/f3xx/PWMInputf3xx.cpp
@ActuallyTaylor ActuallyTaylor requested a review from a team June 7, 2026 17:14
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.

3 participants