Enforce specific ErrorCodes bitmask values

pull/286/head
D.R.racer 2023-07-28 16:59:48 +02:00
parent 2676e063c1
commit 9364056bbf
1 changed files with 5 additions and 0 deletions

View File

@ -44,6 +44,11 @@ static ErrorCode TMC2130ToErrorCode(const hal::tmc2130::ErrorFlags &ef) {
}
ErrorCode __attribute__((noinline)) AddErrorAxisBit(ErrorCode ec, uint8_t axis) {
// From now on, we rely on specific ErrorCode bitmask values - that allowed some important optimizations.
// In case someone fiddles with the bits, the build must fail.
static_assert((uint16_t)ErrorCode::TMC_PULLEY_BIT == 0x0040);
static_assert((uint16_t)ErrorCode::TMC_SELECTOR_BIT == 0x0080);
static_assert((uint16_t)ErrorCode::TMC_IDLER_BIT == 0x0100);
return ec |= (ErrorCode::TMC_PULLEY_BIT << axis);
}