can.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /**
  2. ******************************************************************************
  3. * File Name : CAN.h
  4. * Description : This file provides code for the configuration
  5. * of the CAN instances.
  6. ******************************************************************************
  7. ** This notice applies to any and all portions of this file
  8. * that are not between comment pairs USER CODE BEGIN and
  9. * USER CODE END. Other portions of this file, whether
  10. * inserted by the user or by software development tools
  11. * are owned by their respective copyright owners.
  12. *
  13. * COPYRIGHT(c) 2019 STMicroelectronics
  14. *
  15. * Redistribution and use in source and binary forms, with or without modification,
  16. * are permitted provided that the following conditions are met:
  17. * 1. Redistributions of source code must retain the above copyright notice,
  18. * this list of conditions and the following disclaimer.
  19. * 2. Redistributions in binary form must reproduce the above copyright notice,
  20. * this list of conditions and the following disclaimer in the documentation
  21. * and/or other materials provided with the distribution.
  22. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  23. * may be used to endorse or promote products derived from this software
  24. * without specific prior written permission.
  25. *
  26. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  27. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  29. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  30. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  31. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  32. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  33. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  34. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  35. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  36. *
  37. ******************************************************************************
  38. */
  39. /* Define to prevent recursive inclusion -------------------------------------*/
  40. #ifndef __can_H
  41. #define __can_H
  42. #ifdef __cplusplus
  43. extern "C" {
  44. #endif
  45. /* Includes ------------------------------------------------------------------*/
  46. #include "stm32f1xx_hal.h"
  47. #include "main.h"
  48. /* USER CODE BEGIN Includes */
  49. /* USER CODE END Includes */
  50. extern CAN_HandleTypeDef hcan;
  51. /* USER CODE BEGIN Private defines */
  52. #define ID_MC_BC 0x710
  53. #define ID_MC_TO_BMS 0x712
  54. #define ID_MC_TO_PBU 0x713
  55. #define ID_MC_TO_HMI 0x714
  56. #define ID_MC_TO_CDL 0x715
  57. #define ID_MC_TE_TO_CDL 0x615
  58. #define ID_BMS_BC 0x720
  59. #define ID_BMS_TO_MC 0x721
  60. #define ID_BMS_TO_PBU 0x723
  61. #define ID_BMS_TO_HMI 0x724
  62. #define ID_BMS_TO_CDL 0x725
  63. #define ID_PBU_BC 0x730
  64. #define ID_PBU_TO_MC 0x731
  65. #define ID_PBU_TO_BMS 0x732
  66. #define ID_PBU_TO_HMI 0x734
  67. #define ID_PBU_TO_CDL 0x735
  68. #define ID_PBU_TE_TO_CDL 0x635
  69. #define ID_HMI_BC 0x740
  70. #define ID_HMI_TO_MC 0x741
  71. #define ID_HMI_TO_BMS 0x742
  72. #define ID_HMI_TO_PBU 0x743
  73. #define ID_HMI_TO_CDL 0x745
  74. #define ID_CDL_BC 0x750
  75. #define ID_CDL_TO_MC 0x751
  76. #define ID_CDL_TO_BMS 0x752
  77. #define ID_CDL_TO_PBU 0x753
  78. #define ID_CDL_TO_HMI 0x754
  79. #define ID_CDL_TO_MC_TE 0x651
  80. #define ID_CDL_TO_PBU_TE 0x653
  81. #define ID_TO_CDL_FILTER (uint16_t)(0x705 & 0x605)
  82. #define ID_TO_CDL_MASK (uint16_t)(0x70F & 0x60F)
  83. #define ID_BC_FILTER (uint16_t)(0x700 & 0x700)
  84. #define ID_BC_MASK (uint16_t)(0x70F & 0x60F)
  85. typedef struct
  86. {
  87. uint16_t ucBufID;
  88. uint16_t ucBufSize; //缓冲区数组:缓冲区大小
  89. uint16_t ucBufWrInde; //缓冲区数组:写指针
  90. uint16_t ucBufRdInde; //缓冲区数组:读指针
  91. uint16_t ucBufCnt; //缓冲区数组:数据计数
  92. uint8_t ucBufOvf; //缓冲区数组:溢出标志,注意清零
  93. uint8_t * pcBufAddr; //缓冲区数组:首地址指针变量
  94. uint32_t DelayTimeCnt; //超时计时
  95. TrueOrFalse_Flag_Struct_t IsWaitRX_Flag; //超时等待数据标志
  96. }CAN_Buf_TypeDef;
  97. /* USER CODE END Private defines */
  98. extern void _Error_Handler(char *, int);
  99. void MX_CAN_Init(void);
  100. /* USER CODE BEGIN Prototypes */
  101. #define CAN_BUFF_SIZE 1024
  102. extern uint8_t CAN_RxBuf_MC_BC[CAN_BUFF_SIZE];
  103. extern CAN_Buf_TypeDef CAN_RxBuf_Struct_MC_BC;
  104. extern uint8_t CAN_RxBuf_MC_TO_CDL[CAN_BUFF_SIZE];
  105. extern CAN_Buf_TypeDef CAN_RxBuf_Struct_MC_TO_CDL;
  106. extern uint8_t CAN_RxBuf_MC_TE_TO_CDL[CAN_BUFF_SIZE];
  107. extern CAN_Buf_TypeDef CAN_RxBuf_Struct_MC_TE_TO_CDL;
  108. extern uint8_t CAN_RxBuf_PBU_BC[CAN_BUFF_SIZE];
  109. extern CAN_Buf_TypeDef CAN_RxBuf_Struct_PBU_BC;
  110. extern uint8_t CAN_RxBuf_PBU_TO_CDL[CAN_BUFF_SIZE];
  111. extern CAN_Buf_TypeDef CAN_RxBuf_Struct_PBU_TO_CDL;
  112. extern uint8_t CAN_RxBuf_PBU_TE_TO_CDL[CAN_BUFF_SIZE];
  113. extern CAN_Buf_TypeDef CAN_RxBuf_Struct_PBU_TE_TO_CDL;
  114. extern uint8_t CAN_RxBuf_BMS_BC[CAN_BUFF_SIZE];
  115. extern CAN_Buf_TypeDef CAN_RxBuf_Struct_BMS_BC;
  116. extern uint8_t CAN_RxBuf_BMS_TO_CDL[CAN_BUFF_SIZE];
  117. extern CAN_Buf_TypeDef CAN_RxBuf_Struct_BMS_TO_CDL;
  118. extern uint8_t CAN_RxBuf_HMI_BC[CAN_BUFF_SIZE];
  119. extern CAN_Buf_TypeDef CAN_RxBuf_Struct_HMI_BC;
  120. extern uint8_t CAN_RxBuf_HMI_TO_CDL[CAN_BUFF_SIZE];
  121. extern CAN_Buf_TypeDef CAN_RxBuf_Struct_HMI_TO_CDL;
  122. extern void CAN_SendData(uint16_t ID, uint8_t *Data, uint16_t Length);
  123. extern void CANFilterConfig_Scale32_IdMask_StandardIdOnly(void);
  124. /* USER CODE END Prototypes */
  125. #ifdef __cplusplus
  126. }
  127. #endif
  128. #endif /*__ can_H */
  129. /**
  130. * @}
  131. */
  132. /**
  133. * @}
  134. */
  135. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/