Skip to content

Commit

Permalink
🐛 Fix div_t vs ldiv_t in can.hpp
Browse files Browse the repository at this point in the history
  • Loading branch information
kammce committed May 13, 2024
1 parent eef6f50 commit e622f95
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/5.0.1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: 🚀 5.0.1

on:
workflow_dispatch:

jobs:
deploy:
uses: libhal/ci/.github/workflows/[email protected]
with:
version: 5.0.1
secrets: inherit
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,3 @@ See [`CONTRIBUTING.md`](CONTRIBUTING.md) for details.
## License

Apache 2.0; see [`LICENSE`](LICENSE) for details.

## Disclaimer

This project is not an official Google project. It is not supported by
Google and Google specifically disclaims all warranties as to its quality,
merchantability, or fitness for a particular purpose.
5 changes: 4 additions & 1 deletion include/libhal-util/can.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,13 @@ struct can_bus_divider_t
std::int32_t operating_frequency = p_operating_frequency;
std::int32_t desired_baud_rate = p_target_baud_rate;

std::div_t division{};
using inner_div_t =
decltype(std::div(operating_frequency, desired_baud_rate));
inner_div_t division{};

for (std::uint32_t total_tq = 25; total_tq >= 8; total_tq--) {
division = std::div(operating_frequency, (desired_baud_rate * total_tq));

if (division.rem == 0) {
timing.total_tq = total_tq;
break;
Expand Down

0 comments on commit e622f95

Please sign in to comment.