drv_can.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. #ifndef __DRV_CAN_H__
  11. #define __DRV_CAN_H__
  12. #include <rtdevice.h>
  13. #include <rtthread.h>
  14. #include <board.h>
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. struct n32_baud_rate_tab
  19. {
  20. uint32_t baud_rate;
  21. uint16_t PRESCALE;
  22. uint8_t RSJW;
  23. uint8_t TBS1;
  24. uint8_t TBS2;
  25. uint8_t Reserved;
  26. };
  27. #define N32_CAN_BAUD_DEF(rate, rsjw, tbs1, tbs2, prescale) \
  28. { \
  29. .baud_rate = rate, \
  30. .RSJW = rsjw, \
  31. .TBS1 = tbs1, \
  32. .TBS2 = tbs2, \
  33. .PRESCALE = prescale \
  34. }
  35. /* n32 can device */
  36. struct n32_can
  37. {
  38. char *name;
  39. CAN_Module *CANx;
  40. CAN_InitType can_init;
  41. CAN_FilterInitType FilterConfig;
  42. struct rt_can_device device; /* inherit from can device */
  43. };
  44. int rt_hw_can_init(void);
  45. #ifdef __cplusplus
  46. }
  47. #endif
  48. #endif /* __DRV_CAN_H__ */