flexcan.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /******************************************************************************
  2. 版权所有:
  3. 文件名称: flexcan.h
  4. 文件版本: 01.01
  5. 创建作者: sunxi
  6. 创建日期: 2013-02-03
  7. 功能说明: FLEXCAN驱动
  8. 其它说明:
  9. 修改记录:
  10. */
  11. #ifndef _FLEXCAN_H
  12. #define _FLEXCAN_H
  13. /*------------------------------- 头文件 --------------------------------------
  14. */
  15. #include "rt_types.h"
  16. /*------------------------------- 宏定义 --------------------------------------
  17. */
  18. #define RT_CAN_NUM 4 // 原始can数量
  19. #define RT_CAN_DEV_TYPE 4 // can设备类型
  20. #define RT_M_CAN0 0x0453C800
  21. #define RT_M_RAM0 0x04538000
  22. #define RT_M_TOP0 0x04530000
  23. #define RT_M_DMA0 0x04534000
  24. #define RT_M_CAN1 0x04541800
  25. #define RT_M_RAM1 0x0453D000
  26. #define RT_M_TOP1 0x04531000
  27. #define RT_M_DMA1 0x04535000
  28. #define RT_M_CAN2 0x04546800
  29. #define RT_M_RAM2 0x04542000
  30. #define RT_M_TOP2 0x04532000
  31. #define RT_M_DMA2 0x04536000
  32. #define RT_M_CAN3 0x0454B800
  33. #define RT_M_RAM3 0x04547000
  34. #define RT_M_TOP3 0x04533000
  35. #define RT_M_DMA3 0x04537000
  36. #define CAN_BUS_NUM 2 // 底板支持的CAN总线数量
  37. #define CAN_BUS_ADDR_NUM 16 // 底板支持的插槽数量(与CAN地址数量一一对应)
  38. #define CAN_BUS_ADDR_BCAST 0X0F // 广播地址
  39. #define CAN_FRAME_LEN_MAX 256
  40. #define CAN_MB 16 // can buffer
  41. #define MB_CNT_CODE(x) (((x)&0x0F)<<24)
  42. typedef int (*FN_CAN_RECV_CALLBACK)(u32 no,u8 * buf);
  43. /*------------------------------ 类型结构 -------------------------------------
  44. */
  45. struct can_frame_head
  46. {
  47. u8 type;
  48. u8 dst;
  49. u8 src;
  50. u8 len;
  51. };
  52. /*------------------------------ 函数声明 -------------------------------------
  53. */
  54. int can_init(void);
  55. int can_exit(void);
  56. int can_regester_recv_callback(FN_CAN_RECV_CALLBACK fn);
  57. u8 * can_request_tx_buf(u8 type);
  58. int can_send(u32 no,u8 *buf);
  59. int can_recv(u32 no,u8 *buf,u32 len);
  60. int can_stat(void);
  61. int can_stat_reset(void);
  62. int can_test(void);
  63. #endif //_FLEXCAN_H
  64. /*------------------------------ 文件结束 -------------------------------------
  65. */