drv_can_v2.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2024-08-30 shelton first version
  9. */
  10. #ifndef __DRV_CAN_H__
  11. #define __DRV_CAN_H__
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. #include <rtdevice.h>
  16. #include <rtthread.h>
  17. #include "drv_common.h"
  18. #define CANFD_DATA_1MBaud (1*1000*1000UL)
  19. #define CANFD_DATA_2MBaud (2*1000*1000UL)
  20. #define CANFD_DATA_3MBaud (3*1000*1000UL)
  21. #define CANFD_DATA_4MBaud (4*1000*1000UL)
  22. #define CANFD_DATA_5MBaud (5*1000*1000UL)
  23. #define CANFD_DATA_6MBaud (6*1000*1000UL)
  24. struct at32_baud_rate
  25. {
  26. rt_uint32_t baud_rate;
  27. rt_uint8_t div;
  28. rt_uint8_t rsaw_size;
  29. rt_uint16_t bts1_size;
  30. rt_uint8_t bts2_size;
  31. };
  32. struct at32_baud_rate_fd
  33. {
  34. rt_uint32_t baud_rate;
  35. rt_uint8_t div;
  36. rt_uint8_t rsaw_size;
  37. rt_uint16_t bts1_size;
  38. rt_uint8_t bts2_size;
  39. rt_uint16_t ssoffset;
  40. };
  41. /* at32 can device */
  42. struct at32_can
  43. {
  44. char *name;
  45. can_type *can_x;
  46. IRQn_Type tx_irqn;
  47. IRQn_Type rx_irqn;
  48. IRQn_Type stat_irqn;
  49. IRQn_Type err_irqn;
  50. uint8_t enable_canfd;
  51. can_bittime_type bittime_init_struct;
  52. can_filter_config_type filter_init_struct;
  53. struct rt_can_device device; /* inherit from can device */
  54. };
  55. int rt_hw_can_init(void);
  56. #ifdef __cplusplus
  57. }
  58. #endif
  59. #endif /*__DRV_CAN_H__ */
  60. /************************** end of file ******************/