1 /* 2 * Copyright (C) 2022-2024, Xiaohua Semiconductor Co., Ltd. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2022-04-28 CDT first version 9 */ 10 11 #ifndef __DRV_CAN_H__ 12 #define __DRV_CAN_H__ 13 14 #ifdef __cplusplus 15 extern "C" { 16 #endif 17 18 #include <board.h> 19 #include <rtdevice.h> 20 #include <rtthread.h> 21 22 /* attention !!! 23 * if RT_CAN_USING_CANFD is enabled, RT_CAN_CMD_SET_BITTIMING is more recommended 24 * than RT_CAN_CMD_SET_BAUD_FD. 25 * because sample point is not specified by config when using RT_CAN_CMD_SET_BAUD_FD 26 * but in range [CAN_SAMPLEPOINT_MIN/1000,CAN_SAMPLEPOINT_MAX/1000] 27 * this may not match with your application 28 */ 29 #define CAN_SAMPLEPOINT_MIN (750U) 30 #define CAN_SAMPLEPOINT_MAX (800U) 31 32 #define CAN_CLOCK_SRC_20M (20*1000*1000UL) 33 #define CAN_CLOCK_SRC_40M (40*1000*1000UL) 34 #define CAN_CLOCK_SRC_80M (80*1000*1000UL) 35 36 #define CANFD_ARBITRATION_BAUD_250K (250*1000UL) 37 #define CANFD_ARBITRATION_BAUD_500K (500*1000UL) 38 39 #define CANFD_DATA_BAUD_1M (1*1000*1000UL) 40 #define CANFD_DATA_BAUD_2M (2*1000*1000UL) 41 #define CANFD_DATA_BAUD_4M (4*1000*1000UL) 42 #define CANFD_DATA_BAUD_5M (5*1000*1000UL) 43 #define CANFD_DATA_BAUD_8M (8*1000*1000UL) 44 45 #define CAN_FRAME_CLASSIC (0x0U) 46 #define CAN_FRAME_ISO_FD (0x2U) 47 #define CAN_FRAME_NON_ISO_FD (0x4U) 48 49 /* hc32 can device */ 50 struct can_dev_init_params 51 { 52 char *name; 53 rt_bool_t single_trans_mode; 54 }; 55 56 int rt_hw_can_init(void); 57 58 #ifdef __cplusplus 59 } 60 #endif 61 62 #endif /*__DRV_CAN_H__ */ 63 64 /************************** end of file ******************/ 65