zephyr/drivers/can/can_utils.h
Julien Massot d79044cd2b drivers: can: mcp2515: move filter_match function
Move filter match function to can_utils.h, so that it
can be reused for Renesas driver.

Preserve copyright from Karsten Koenig.

Signed-off-by: Julien Massot <julien.massot@iot.bzh>
2021-06-07 12:06:21 +02:00

33 lines
604 B
C

/*
* Copyright (c) 2018 Karsten Koenig
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file Header where utility code can be found for CAN drivers
*/
#ifndef ZEPHYR_DRIVERS_CAN_CAN_UTILS_H_
#define ZEPHYR_DRIVERS_CAN_CAN_UTILS_H_
static inline uint8_t can_utils_filter_match(const struct zcan_frame *msg,
struct zcan_filter *filter)
{
if (msg->id_type != filter->id_type) {
return 0;
}
if ((msg->rtr ^ filter->rtr) & filter->rtr_mask) {
return 0;
}
if ((msg->id ^ filter->id) & filter->id_mask) {
return 0;
}
return 1;
}
#endif /* ZEPHYR_DRIVERS_CAN_CAN_UTILS_H_ */