Skip to content

An Old Timer's Tears [FWT-243]#125

Merged
aclowmclaughlin merged 92 commits into
mainfrom
feature/actuallytaylor/timer_refactor
Jan 30, 2026
Merged

An Old Timer's Tears [FWT-243]#125
aclowmclaughlin merged 92 commits into
mainfrom
feature/actuallytaylor/timer_refactor

Conversation

@ActuallyTaylor

Copy link
Copy Markdown
Member

Refactors timers to use a common core that can be subclassed by other timer like objects (PWM atm).

Additions:

  • Timer: A .hpp only class that defines what a timer looks like. Also contains the definition for TimerConfiguration.

Changes:

  • TimerF4xx is acpp & hpp file that defines a Timer implementation for for the F3 boards.
  • TimerF3xx is a cpp & hpp file that defines a Timer implementation for for the F4 boards.
  • `PWMf3xx is now a subclass of TimerF3xx, allows for PWM to control its own timers using the standard F3 timer implementation.
  • ADC F3 & F4: Both now use the new timer implementations.

Tested

  • All timers on F302
  • All timers on F334
  • All timers on F446
  • PWM on F302
  • PWM on F334
  • ADC on F302
  • ADC on F334
  • ADC on F446

ActuallyTaylor and others added 30 commits March 3, 2025 20:37
Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
… and after a CAN interrupt. This is mainly so that we can make sure CAN interrupts can be made threadsafe for the rtos by calling some threadx methods before the interrupt.
As far as I know (from looking through the files), CAN, Timer, and RTC all look like they are now supported by F4. Please correct me if I am wrong!

Also, is CANopen automatically supported if CAN is now supported?

@aclowmclaughlin aclowmclaughlin 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.

This is super impressive and it is really well detailed. Everything is really minor and mostly commenting changes.
I really do agree that passing in an extre void* argument in the interrupts is not a significant code burden to implement but will be an incredible boon for the code.
HOWEVER, if there's more overhead to doing that then I'm really predicting, then by all means we should probably have it be a separate request, I'm just thinking that it won't be that big a burden.

Comment thread include/core/dev/MCUTimer.hpp
Comment thread include/core/dev/Timer.hpp Outdated
Comment thread include/core/dev/Timer.hpp Outdated
Comment thread include/core/dev/platform/f3xx/Timerf3xx.hpp Outdated
Comment thread include/core/dev/platform/f3xx/Timerf3xx.hpp
Comment thread include/core/manager.hpp Outdated
Comment thread samples/timer_configuration/main.cpp Outdated
Comment thread src/core/dev/RTCTimer.cpp Outdated
#define F302_TIMER_COUNT 5

TIM_HandleTypeDef halTimers[F302_TIMER_COUNT];
void (*timerInterruptHandlers[F302_TIMER_COUNT])(void* htim) = {nullptr};

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.

I do kind of agree- I think it is within the scope of the PR and it's pretty significant utility- I can attest firsthand that when you don't have the option to just pass in a void* you have to do weird stuff to work around that.

Comment thread src/core/dev/platform/f3xx/Timerf3xx.cpp
ActuallyTaylor and others added 17 commits November 8, 2025 12:25
Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
Updated the supported timers for each board in the comments on the respective concrete implementations.

Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
Before this they were being copy and pasted, this should properly inherit.

Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
RTCTimer was complaining since setPeriod was pure virtual.

Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
it was removed while people were testing

Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
TimerClockDivision, and TimerCounterMode have been commented.
Renamed TimerAutoReloadPreload enum values to better represent that they are BUFFER and NO_BUFFER

Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
The docs for these are not complete, many of these options have limited information on the internet, and could 100% benefit from physical trial and error with an EE.

Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
ActuallyTaylor and others added 2 commits November 17, 2025 19:22
Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
@ActuallyTaylor ActuallyTaylor requested a review from a team January 15, 2026 18:06

@aclowmclaughlin aclowmclaughlin 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.

This looks really good to me. Stellar work.
I had a couple of questions but I don't think any of them were important enough to stop me from approving the PR.

Comment thread include/core/dev/RTCTimer.hpp
Comment thread include/core/dev/RTCTimer.hpp Outdated
Comment thread include/core/dev/Timer.hpp
Comment thread samples/pwm/main.cpp Outdated
Comment thread src/core/io/platform/f4xx/ADCf4xx.cpp

@DiegoLHendrix DiegoLHendrix 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.

Looks good to me

@aclowmclaughlin aclowmclaughlin merged commit d02a9bd into main Jan 30, 2026
1 check passed
@aclowmclaughlin aclowmclaughlin deleted the feature/actuallytaylor/timer_refactor branch January 30, 2026 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants