1 /* 2 * Copyright (c) 2006-2022, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2022-10-19 Nations first version 9 */ 10 11 #ifndef __DRV_CAN_H__ 12 #define __DRV_CAN_H__ 13 14 #include <rtdevice.h> 15 #include <rtthread.h> 16 #include <board.h> 17 18 #ifdef __cplusplus 19 extern "C" { 20 #endif 21 22 struct n32_baud_rate_tab 23 { 24 uint32_t baud_rate; 25 uint16_t PRESCALE; 26 uint8_t RSJW; 27 uint8_t TBS1; 28 uint8_t TBS2; 29 uint8_t Reserved; 30 }; 31 32 #define N32_CAN_BAUD_DEF(rate, rsjw, tbs1, tbs2, prescale) \ 33 { \ 34 .baud_rate = rate, \ 35 .RSJW = rsjw, \ 36 .TBS1 = tbs1, \ 37 .TBS2 = tbs2, \ 38 .PRESCALE = prescale \ 39 } 40 41 /* n32 can device */ 42 struct n32_can 43 { 44 char *name; 45 CAN_Module *CANx; 46 CAN_InitType can_init; 47 CAN_FilterInitType FilterConfig; 48 struct rt_can_device device; /* inherit from can device */ 49 }; 50 51 int rt_hw_can_init(void); 52 53 #ifdef __cplusplus 54 } 55 #endif 56 57 #endif /* __DRV_CAN_H__ */ 58