Skip to content

Commit

Permalink
[build] Fix multiple compilation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed Jan 12, 2024
1 parent 79e7e22 commit 2afca50
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion ext/hathach/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,9 @@ Configuration options:

def build(self, env):
env.outbasepath = "modm/ext/tinyusb"
env.copy("tinyusb/src/device/", "device/")
operations = env.copy("tinyusb/src/device/", "device/")
operations = [o for o in operations if "usbd.c" in o.filename]
env.collect(":build:ccflags", "-Wno-bad-function-cast", operations=operations)


# -----------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/modm/platform/i2c/sam_x7x/i2c_master.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ private:
constexpr bool fastMode = baudrate > 125'000;
// Baudrate threshold above which the low time is fixed to the minimum value of
// 1.3us in fast mode or 4.7us in standard mode.
constexpr auto minLowTime = fastMode ? 1.3e-6 : 4.7e-6;
constexpr auto minLowTime = fastMode ? 1.3e-6f : 4.7e-6f;
constexpr auto minLowTimeLimit = 1.f / (2*minLowTime);

// t_high = ((CHDIV * 2^CKDIV) + 3) * (1 / peripheral clock)
// t_low = ((CLDIV * 2^CKDIV) + 3) * (1 / peripheral clock)
if constexpr (baudrate > minLowTimeLimit) {
// calculate ideal low and high prescaler values (formula from ASF vendor HAL)
constexpr auto cldiv = uint32_t(std::round((minLowTime * clock) - 3));
constexpr auto tHigh = 1.f / ((baudrate + (baudrate - minLowTimeLimit)) * 2.f);
constexpr auto tHigh = 1.f / ((baudrate + float(baudrate - minLowTimeLimit)) * 2.f);
constexpr auto chdiv = uint32_t(std::round((tHigh * clock) - 3));

// use 2^N pre-divider if max. prescaler exceeds 8 bits
Expand Down

0 comments on commit 2afca50

Please sign in to comment.