drivers: can: Add get_max_filters API

The maximum number of concurrent filters depends on the hardware and
the driver implementation. This API allows the application to obtain
the maximum number of available filters.

Signed-off-by: Martin Jäger <martin@libre.solar>
This commit is contained in:
Martin Jäger 2021-10-12 11:46:44 +02:00 committed by Christopher Friedt
commit 5511cba5fe
7 changed files with 78 additions and 0 deletions

View file

@ -38,6 +38,15 @@ int can_stm32fd_get_core_clock(const struct device *dev, uint32_t *rate)
return 0;
}
int can_stm32fd_get_max_filters(const struct device *dev, enum can_ide id_type)
{
if (id_type == CAN_STANDARD_IDENTIFIER) {
return NUM_STD_FILTER_DATA;
} else {
return NUM_EXT_FILTER_DATA;
}
}
void can_stm32fd_clock_enable(void)
{
LL_RCC_SetFDCANClockSource(LL_RCC_FDCAN_CLKSOURCE_PCLK1);
@ -175,6 +184,7 @@ static const struct can_driver_api can_api_funcs = {
.recover = can_mcan_recover,
#endif
.get_core_clock = can_stm32fd_get_core_clock,
.get_max_filters = can_stm32fd_get_max_filters,
.register_state_change_isr = can_stm32fd_register_state_change_isr,
.timing_min = {
.sjw = 0x7f,