forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcan_utils.h
39 lines (32 loc) · 812 Bytes
/
can_utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
* 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_
/**
* @brief Check if a CAN filter matches a CAN frame
*
* @param frame CAN frame.
* @param filter CAN filter.
* @return true if the CAN filter matches the CAN frame, false otherwise
*/
static inline bool can_utils_filter_match(const struct can_frame *frame,
struct can_filter *filter)
{
if (frame->id_type != filter->id_type) {
return false;
}
if ((frame->rtr ^ filter->rtr) & filter->rtr_mask) {
return false;
}
if ((frame->id ^ filter->id) & filter->id_mask) {
return false;
}
return true;
}
#endif /* ZEPHYR_DRIVERS_CAN_CAN_UTILS_H_ */