FDCAN HAL bug in assert-check for number of filters
Hi All - minor issue I noticed earlier on a Nucleo H563ZI board when configuring the FDCAN filters.
With asserts enabled, if I set the allowed maximum filters to a non-zero number and try to set a filter on a higher filter index, it raises an assert as expected. But if the allowed number of filters is 0, it does not.
I believe this is because the assert is implemented at line 1332 in stm32h5xx_hal_fdcan.c as:
assert_param(IS_FDCAN_MAX_VALUE(sFilterConfig->FilterIndex, (hfdcan->Init.ExtFiltersNbr - 1U)));
Init.ExtFiltersNbr is an unsigned integer, so (Init.ExtFiltersNbr - 1) as passed to the IS_FDCAN_MAX_VALUE test will be wrapped-around to a large number?
This may be better implemented as:
assert_param(IS_FDCAN_MAX_VALUE((sFilterConfig->FilterIndex + 1U), hfdcan->Init.ExtFiltersNbr ));
Nic
