1 /* 2 * Copyright (c) 2023 Vestas Wind Systems A/S 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include <zephyr/drivers/can.h> 8 #include <zephyr/ztest.h> 9 10 #include "common.h" 11 12 /** 13 * @addtogroup t_driver_can 14 * @{ 15 * @defgroup t_can_stats test_can_stats 16 * @} 17 */ 18 19 /** 20 * @brief Test that CAN statistics can be accessed from user mode threads. 21 */ ZTEST_USER(can_stats,test_can_stats_accessors)22ZTEST_USER(can_stats, test_can_stats_accessors) 23 { 24 uint32_t val; 25 26 val = can_stats_get_bit_errors(can_dev); 27 val = can_stats_get_bit0_errors(can_dev); 28 val = can_stats_get_bit1_errors(can_dev); 29 val = can_stats_get_stuff_errors(can_dev); 30 val = can_stats_get_crc_errors(can_dev); 31 val = can_stats_get_form_errors(can_dev); 32 val = can_stats_get_ack_errors(can_dev); 33 val = can_stats_get_rx_overruns(can_dev); 34 } 35 can_stats_setup(void)36void *can_stats_setup(void) 37 { 38 k_object_access_grant(can_dev, k_current_get()); 39 40 zassert_true(device_is_ready(can_dev), "CAN device not ready"); 41 42 return NULL; 43 } 44 45 ZTEST_SUITE(can_stats, NULL, can_stats_setup, NULL, NULL, NULL); 46