drv_can.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright (c) 2006-2018, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2018-08-05 Xeon Xu the first version
  9. * 2019-01-22 YLZ port from stm324xx-HAL to bsp stm3210x-HAL
  10. * 2019-01-26 YLZ redefine `struct stm32_drv_can` add member `Rx1Message`
  11. * 2019-02-19 YLZ port to BSP [stm32]
  12. * 2019-06-17 YLZ modify struct stm32_drv_can.
  13. */
  14. #ifndef __DRV_CAN_H__
  15. #define __DRV_CAN_H__
  16. #include <board.h>
  17. #include <rtdevice.h>
  18. #include <rthw.h>
  19. #include <rtthread.h>
  20. #define BS1SHIFT 16
  21. #define BS2SHIFT 20
  22. #define RRESCLSHIFT 0
  23. #define SJWSHIFT 24
  24. #define BS1MASK ( (0x0F) << BS1SHIFT )
  25. #define BS2MASK ( (0x07) << BS2SHIFT )
  26. #define RRESCLMASK ( 0x3FF << RRESCLSHIFT )
  27. #define SJWMASK ( 0x3 << SJWSHIFT )
  28. struct stm_baud_rate_tab
  29. {
  30. rt_uint32_t baud_rate;
  31. rt_uint32_t confdata;
  32. };
  33. /* STM32 can driver */
  34. struct stm32_drv_can
  35. {
  36. CAN_HandleTypeDef CanHandle;
  37. CAN_FilterTypeDef FilterConfig;
  38. };
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42. int rt_hw_can_init(void);
  43. #ifdef __cplusplus
  44. }
  45. #endif
  46. #endif /*__DRV_CAN_H__ */