can.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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_BMS_BC 0x720
  58. #define ID_BMS_TO_MC 0x721
  59. #define ID_BMS_TO_PBU 0x723
  60. #define ID_BMS_TO_HMI 0x724
  61. #define ID_BMS_TO_CDL 0x725
  62. #define ID_PBU_BC 0x730
  63. #define ID_PBU_TO_MC 0x731
  64. #define ID_PBU_TO_BMS 0x732
  65. #define ID_PBU_TO_HMI 0x734
  66. #define ID_PBU_TO_CDL 0x735
  67. #define ID_HMI_BC 0x740
  68. #define ID_HMI_TO_MC 0x741
  69. #define ID_HMI_TO_BMS 0x742
  70. #define ID_HMI_TO_PBU 0x743
  71. #define ID_HMI_TO_CDL 0x745
  72. #define ID_CDL_BC 0x750
  73. #define ID_CDL_TO_MC 0x751
  74. #define ID_CDL_TO_BMS 0x752
  75. #define ID_CDL_TO_PBU 0x753
  76. #define ID_CDL_TO_HMI 0x754
  77. #define ID_TO_MC_FILTER (uint16_t)(0x701 & 0x605)
  78. #define ID_TO_MC_MASK (uint16_t)(0x70F & 0x60F)
  79. #define ID_BC_FILTER (uint16_t)(0x700 & 0x700)
  80. #define ID_BC_MASK (uint16_t)(0x70F & 0x60F)
  81. #define ID_CDL_TO_MC_TE 0x651
  82. #define ID_MC_TE_TO_CDL 0x615
  83. typedef struct
  84. {
  85. uint16_t ucBufID;
  86. uint8_t ucBufSize; //缓冲区数组:缓冲区大小
  87. uint8_t ucBufWrInde; //缓冲区数组:写指针
  88. uint8_t ucBufRdInde; //缓冲区数组:读指针
  89. uint8_t ucBufCnt; //缓冲区数组:数据计数
  90. uint8_t ucBufOvf; //缓冲区数组:溢出标志,注意清零
  91. uint8_t * pcBufAddr; //缓冲区数组:首地址指针变量
  92. uint32_t DelayTimeCnt; //超时计时
  93. TrueOrFalse_Flag_Struct_t IsWaitRX_Flag; //超时等待数据标志
  94. }CAN_Buf_TypeDef;
  95. /* USER CODE END Private defines */
  96. extern void _Error_Handler(char *, int);
  97. void MX_CAN_Init(void);
  98. /* USER CODE BEGIN Prototypes */
  99. extern uint8_t CAN_RxBuf_PBU[255];
  100. extern CAN_Buf_TypeDef CAN_RxBuf_Struct_PBU;
  101. extern uint8_t CAN_RxBuf_BMS[255];
  102. extern CAN_Buf_TypeDef CAN_RxBuf_Struct_BMS;
  103. extern uint8_t CAN_RxBuf_HMI[255];
  104. extern CAN_Buf_TypeDef CAN_RxBuf_Struct_HMI;
  105. extern uint8_t CAN_RxBuf_CDL[255];
  106. extern CAN_Buf_TypeDef CAN_RxBuf_Struct_CDL;
  107. extern void CAN_SendData(uint16_t ID, uint8_t *Data, uint16_t Length);
  108. extern void CANFilterConfig_Scale32_IdMask_StandardIdOnly(void);
  109. /* USER CODE END Prototypes */
  110. #ifdef __cplusplus
  111. }
  112. #endif
  113. #endif /*__ can_H */
  114. /**
  115. * @}
  116. */
  117. /**
  118. * @}
  119. */
  120. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/