Skip to content

Conversation

@XanBu
Copy link

@XanBu XanBu commented Sep 12, 2025

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
Copy link
Member

@ActuallyTaylor ActuallyTaylor left a comment

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.

XanBu and others added 3 commits October 9, 2025 18:16
Left over testing change

Co-authored-by: Taylor Lineman <[email protected]>
Removed extra empty line

Co-authored-by: Taylor Lineman <[email protected]>
@XanBu XanBu requested a review from ActuallyTaylor October 9, 2025 22:26
Copy link
Contributor

@mjh9585 mjh9585 left a comment

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!


namespace core::io {

PWM_INPUT::PWM_INPUT(Pin pin) { // core::io::Pin pin
Copy link
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 on lines 231 to 233
TIM_HandleTypeDef* PWM_INPUTf3xx::getHandle() {
return &halTIM;
}
Copy link
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
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
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
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
Copy link
Member

@ActuallyTaylor ActuallyTaylor left a comment

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.

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.

4 participants