Skip to content

Commit dd468fc

Browse files
congnguyenhuudleach02
authored andcommitted
tests: drivers: can: canfd: add support filter type frame
Add new filter to configure correctly FD frame. Signed-off-by: Cong Nguyen Huu <[email protected]>
1 parent d167d3a commit dd468fc

File tree

1 file changed

+22
-4
lines changed
  • tests/drivers/can/canfd/src

1 file changed

+22
-4
lines changed

tests/drivers/can/canfd/src/main.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,24 @@ const struct can_filter test_std_filter_2 = {
113113
.mask = CAN_STD_ID_MASK
114114
};
115115

116+
/**
117+
* @brief Standard (11-bit) CAN-FD ID filter 1.
118+
*/
119+
const struct can_filter test_std_filter_fd_1 = {
120+
.flags = CAN_FILTER_DATA | CAN_FILTER_FDF,
121+
.id = TEST_CAN_STD_ID_1,
122+
.mask = CAN_STD_ID_MASK
123+
};
124+
125+
/**
126+
* @brief Standard (11-bit) CAN-FD ID filter 2.
127+
*/
128+
const struct can_filter test_std_filter_fd_2 = {
129+
.flags = CAN_FILTER_DATA | CAN_FILTER_FDF,
130+
.id = TEST_CAN_STD_ID_2,
131+
.mask = CAN_STD_ID_MASK
132+
};
133+
116134
/**
117135
* @brief Assert that two CAN frames are equal.
118136
*
@@ -177,7 +195,7 @@ static void rx_std_callback_fd_1(const struct device *dev, struct can_frame *fra
177195

178196
assert_frame_equal(frame, &test_std_frame_fd_1);
179197
zassert_equal(dev, can_dev, "CAN device does not match");
180-
zassert_equal_ptr(filter, &test_std_filter_1, "filter does not match");
198+
zassert_equal_ptr(filter, &test_std_filter_fd_1, "filter does not match");
181199

182200
k_sem_give(&rx_callback_sem);
183201
}
@@ -189,7 +207,7 @@ static void rx_std_callback_fd_2(const struct device *dev, struct can_frame *fra
189207

190208
assert_frame_equal(frame, &test_std_frame_fd_2);
191209
zassert_equal(dev, can_dev, "CAN device does not match");
192-
zassert_equal_ptr(filter, &test_std_filter_2, "filter does not match");
210+
zassert_equal_ptr(filter, &test_std_filter_fd_2, "filter does not match");
193211

194212
k_sem_give(&rx_callback_sem);
195213
}
@@ -363,7 +381,7 @@ ZTEST(canfd, test_send_receive_classic)
363381
*/
364382
ZTEST(canfd, test_send_receive_fd)
365383
{
366-
send_receive(&test_std_filter_1, &test_std_filter_2,
384+
send_receive(&test_std_filter_fd_1, &test_std_filter_fd_2,
367385
&test_std_frame_fd_1, &test_std_frame_fd_2);
368386
}
369387

@@ -372,7 +390,7 @@ ZTEST(canfd, test_send_receive_fd)
372390
*/
373391
ZTEST(canfd, test_send_receive_mixed)
374392
{
375-
send_receive(&test_std_filter_1, &test_std_filter_2,
393+
send_receive(&test_std_filter_fd_1, &test_std_filter_2,
376394
&test_std_frame_fd_1, &test_std_frame_2);
377395
}
378396

0 commit comments

Comments
 (0)