Skip to content

Commit 54a9524

Browse files
Documented why getTIM uses inline.
Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
1 parent 70f0b0c commit 54a9524

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

include/core/dev/MCUTimer.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ enum class MCUTimer {
4545

4646
/**
4747
* Gets the corresponding HAL TIM_TypeDef* for each MCUTimer
48+
* This function is inlined because of a couple of reasons.
49+
* 1. It is in a header file, and functions in header files should be inlined. https://clang.llvm.org/extra/clang-tidy/checks/misc/definitions-in-headers.html
50+
* 2. When this function is not inlined, F3 targets will not build. This is because PWMF3xx requires its own
51+
* `timerInstance` function that requires an MCUTimer import. Since manager.hpp also includes MCUTimer.hpp, and has
52+
* generally broken imports (see [FWT-255] https://rit-evt.atlassian.net/browse/FWT-255).
4853
*
4954
* @param mcuTimer MCUTimer of which to get the HAL equivalent
5055
* @return HAL equivalent of mcuTimer
@@ -68,6 +73,9 @@ inline TIM_TypeDef* getTIM(const MCUTimer mcuTimer) {
6873
case MCUTimer::Timer17:
6974
timPeriph = TIM17;
7075
break;
76+
default:
77+
timPeriph = TIM1;
78+
break;
7179
#elif defined(STM32F334x8)
7280
case MCUTimer::Timer1:
7381
timPeriph = TIM1;
@@ -87,6 +95,9 @@ inline TIM_TypeDef* getTIM(const MCUTimer mcuTimer) {
8795
case MCUTimer::Timer17:
8896
timPeriph = TIM17;
8997
break;
98+
default:
99+
timPeriph = TIM1;
100+
break;
90101
#elif defined(STM32F446xx)
91102
case MCUTimer::Timer1:
92103
timPeriph = TIM1;

0 commit comments

Comments
 (0)