drv_can.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. */
  13. #ifndef __DRV_CAN_H__
  14. #define __DRV_CAN_H__
  15. #include "board.h"
  16. #include <rtdevice.h>
  17. #include <rthw.h>
  18. #include <rtthread.h>
  19. #define BS1SHIFT 16
  20. #define BS2SHIFT 20
  21. #define RRESCLSHIFT 0
  22. #define SJWSHIFT 24
  23. #define BS1MASK ( (0x0F) << BS1SHIFT )
  24. #define BS2MASK ( (0x07) << BS2SHIFT )
  25. #define RRESCLMASK ( 0x3FF << RRESCLSHIFT )
  26. #define SJWMASK ( 0x3 << SJWSHIFT )
  27. struct stm_baud_rate_tab
  28. {
  29. rt_uint32_t baud_rate;
  30. rt_uint32_t confdata;
  31. };
  32. /* STM32 can driver */
  33. struct stm32_drv_can
  34. {
  35. CAN_HandleTypeDef CanHandle;
  36. CanTxMsgTypeDef TxMessage;
  37. CanRxMsgTypeDef RxMessage;
  38. CanRxMsgTypeDef Rx1Message;
  39. CAN_FilterConfTypeDef FilterConfig;
  40. };
  41. #ifdef __cplusplus
  42. extern "C" {
  43. #endif
  44. extern int rt_hw_can_init(void);
  45. #ifdef __cplusplus
  46. }
  47. #endif
  48. #endif /*__DRV_CAN_H__ */