drv_can.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. #ifndef __DRV_CAN_H__
  11. #define __DRV_CAN_H__
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. #include <board.h>
  16. #include <rtdevice.h>
  17. #include <rtthread.h>
  18. /* attention !!!
  19. * if RT_CAN_USING_CANFD is enabled, RT_CAN_CMD_SET_BITTIMING is more recommended
  20. * than RT_CAN_CMD_SET_BAUD_FD.
  21. * because sample point is not specified by config when using RT_CAN_CMD_SET_BAUD_FD
  22. * but in range [CAN_SAMPLEPOINT_MIN/1000,CAN_SAMPLEPOINT_MAX/1000]
  23. * this may not match with your application
  24. */
  25. #define CAN_SAMPLEPOINT_MIN (750U)
  26. #define CAN_SAMPLEPOINT_MAX (800U)
  27. #define CAN_CLOCK_SRC_20M (20*1000*1000UL)
  28. #define CAN_CLOCK_SRC_40M (40*1000*1000UL)
  29. #define CAN_CLOCK_SRC_80M (80*1000*1000UL)
  30. #define CANFD_ARBITRATION_BAUD_250K (250*1000UL)
  31. #define CANFD_ARBITRATION_BAUD_500K (500*1000UL)
  32. #define CANFD_DATA_BAUD_1M (1*1000*1000UL)
  33. #define CANFD_DATA_BAUD_2M (2*1000*1000UL)
  34. #define CANFD_DATA_BAUD_4M (4*1000*1000UL)
  35. #define CANFD_DATA_BAUD_5M (5*1000*1000UL)
  36. #define CANFD_DATA_BAUD_8M (8*1000*1000UL)
  37. #define CAN_FRAME_CLASSIC (0x0U)
  38. #define CAN_FRAME_ISO_FD (0x2U)
  39. #define CAN_FRAME_NON_ISO_FD (0x4U)
  40. /* hc32 can device */
  41. struct can_dev_init_params
  42. {
  43. char *name;
  44. rt_bool_t single_trans_mode;
  45. };
  46. int rt_hw_can_init(void);
  47. #ifdef __cplusplus
  48. }
  49. #endif
  50. #endif /*__DRV_CAN_H__ */
  51. /************************** end of file ******************/