Skip to content

Audit timers HAL #2: Remove channel array#531

Closed
kurtjd wants to merge 1 commit intoOpenDevicePartnership:mainfrom
kurtjd:audit-timers2
Closed

Audit timers HAL #2: Remove channel array#531
kurtjd wants to merge 1 commit intoOpenDevicePartnership:mainfrom
kurtjd:audit-timers2

Conversation

@kurtjd
Copy link
Contributor

@kurtjd kurtjd commented Dec 17, 2025

We can remove the need for indexing into a channel array by just implementing From. We keep the TimerChannelNum enum because this can be determined statically, whereas if we kept channel as just a usize we couldn't get an exhaustive match (and would therefore theoretically be fallible). Tested on hardware. Related: #530

Going to be one more PR after this to remove the unwraps (keeping that separate since it will likely introduce breaking changes).

@kurtjd kurtjd self-assigned this Dec 17, 2025
@kurtjd kurtjd requested a review from a team as a code owner December 17, 2025 18:16
@kurtjd kurtjd added the enhancement New feature or request label Dec 17, 2025
@kurtjd kurtjd moved this to In review in Embedded Controller Dec 17, 2025
Copy link
Contributor

@williampMSFT williampMSFT left a comment

Choose a reason for hiding this comment

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

:shipit:

RobertZ2011 pushed a commit that referenced this pull request Dec 17, 2025
Depends on #531 
Resolves #530 

This removes the last of the panic paths in the timers HAL by removing
unwraps and changing a few constructors to return a `Result` instead
(which introduces a breaking change). A new freq field was added to the
PWM struct since originally, we unwrapped in a PWM trait method which
does not return a `Result`. So, we just verify the clock config is valid
in the constructor and can use the cached freq in the trait methods.
@kurtjd
Copy link
Contributor Author

kurtjd commented Dec 17, 2025

Closing since #532 captures these changes.

@kurtjd kurtjd closed this Dec 17, 2025
@github-project-automation github-project-automation bot moved this from In review to Done in Embedded Controller Dec 17, 2025
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

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants