Enforce specific ErrorCodes bitmask values

pull/288/head
D.R.racer 2023-07-28 16:59:48 +02:00 committed by DRracer
parent 169925fc9f
commit f164a8afa0
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) { 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); return ec |= (ErrorCode::TMC_PULLEY_BIT << axis);
} }