uart_Lidian2.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /**
  2. ******************************************************************************
  3. * @file uartSpecial.h
  4. * @author
  5. * @version V1.0.0
  6. * @date 23-12-2015
  7. * @brief uartSpecial function.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __UART_LIDIAN2_H
  39. #define __UART_LIDIAN2_H
  40. /* Includes ------------------------------------------------------------------*/
  41. #include "usart.h"
  42. /* Define to variables declare---------------------------------------------------*/
  43. //先发高字节再发低字节
  44. typedef union OBC_CtrlInfo1
  45. {
  46. struct
  47. {
  48. UBYTE Curise: 1;
  49. UBYTE Walk: 1;
  50. UBYTE SpeedLimited: 1;//1:超过限速值;0:未超过限速值
  51. UBYTE CuriseTrigMode: 1;
  52. UBYTE CommErr: 1;//0: 通讯正常 1: 通讯故障
  53. UBYTE Light: 1;//灯光控制。0: 关闭 1: 开
  54. UBYTE NonZeroStart: 1;//0: 零启动 1: 非零启动
  55. UBYTE Switch_OnOff: 1;//0: 控制器不工作,1: 控制器工作
  56. } Ctrl_Bit;
  57. UBYTE Ctrl;
  58. } OBC_CtrlInfo1_Struct_t;
  59. typedef union OBC_CtrlInfo2
  60. {
  61. struct
  62. {
  63. UBYTE ucAssistedMagnetSteel: 4;//助力磁钢盘磁钢个数
  64. UBYTE RS1: 1;//备用
  65. UBYTE RS2: 1;//备用
  66. UBYTE CuriseEnabele: 4;//自动巡航标志 0: 无自动巡航, 1: 有自动巡航
  67. UBYTE Reverse: 1;//0: 无效,1: 倒车
  68. } Ctrl_Bit;
  69. UBYTE Ctrl;
  70. } OBC_CtrlInfo2_Struct_t;
  71. typedef struct
  72. {
  73. UBYTE ucPowerStyle;//驱动方式,0-助力驱动,1-电驱动,2-助力驱动和电驱动同时共存
  74. UBYTE ucGearSt;//助力档位
  75. OBC_CtrlInfo1_Struct_t stCtrlInfo1;
  76. UBYTE ucSpeedMagnetSteel; //测速磁钢数
  77. UWORD uwWheelDiameter;//0.1 inch
  78. UBYTE ucAssistSensitivity;//助力灵敏度
  79. UBYTE ucAssistPowerMode;//助力启动强度,0 ~ 5, 0 最弱, 5 最强
  80. UBYTE ucInnerSpeedMagnetSteel;//内测速磁钢数
  81. UBYTE ucSpeedLimiation;//KM/h
  82. UBYTE ucCurrentLimiation;//1A
  83. UWORD uwUnderVoltageLimiation;//0.1V
  84. UWORD uwThrottlePWM;//0.1%
  85. OBC_CtrlInfo2_Struct_t stCtrlInfo2;
  86. } Lidian2_OBC2MCInfo_Struct_t;
  87. typedef union MC_StatusInfo1
  88. {
  89. struct
  90. {
  91. UBYTE RotorLock: 1;//1: 电机缺相
  92. UBYTE BrakeErr: 1;//1: 刹把故障
  93. UBYTE Curise: 1;//1: 巡航状态
  94. UBYTE UnderVoltageErr: 1;//1: 欠压保护
  95. UBYTE ControllerErr: 1;//1: 控制器故障
  96. UBYTE ThrottleErr: 1;//1: 转把故障
  97. UBYTE HallErr: 1;//霍尔故障
  98. UBYTE Walk: 1;//6Km 巡航
  99. } Status_Bit;
  100. UBYTE Status;
  101. } MC_StatusInfo1_Struct_t;
  102. typedef union MC_StatusInfo2
  103. {
  104. struct
  105. {
  106. UBYTE GearSt: 2;//
  107. UBYTE SpeedLimited: 1;//1:限速中
  108. UBYTE Charging: 1;//1:充电中
  109. UBYTE CommErr: 1;//1:通讯故障
  110. UBYTE Brake: 1;//
  111. UBYTE AssistSensorErr: 1;//默认为1
  112. UBYTE Horizontal: 1;//1: 水平状态 0: 非水平状态,默认为1
  113. } Status_Bit;
  114. UBYTE Status;
  115. } MC_StatusInfo2_Struct_t;
  116. typedef struct
  117. {
  118. MC_StatusInfo1_Struct_t stMC_StatusInfo1;
  119. MC_StatusInfo2_Struct_t stMC_StatusInfo2;
  120. UWORD uwCurrent;//0.1A
  121. UBYTE ucCurrentRatio;//电流比例值
  122. UWORD uwSpeed;
  123. UBYTE SOC;//由BMS实现,发0
  124. UWORD uwRemainDistance;//由BMS实现,发0
  125. } Lidian2_MC2OBCInfo_Struct_t;
  126. /* Public variables declare---------------------------------------------------*/
  127. //extern OBC2MCInfo_Struct_t stOBC2MCInfo;
  128. //extern MC2OBCInfo_Struct_t stMC2OBCInfo;
  129. /*Private function declare---------------------------------------------------*/
  130. void Lidian2_OBCSetPara(void);
  131. void Lidian2_USART_DataProcess(USART_Buf_TypeDef* ptUartTx, UBYTE* Data);
  132. void Lidian2_SendData_OBC(USART_Buf_TypeDef* ptUartTx);
  133. void Lidian2_USART_RxData_Process(USART_Buf_TypeDef* ptUartTx, UBYTE* buf, UWORD dataCount);
  134. void Lidian2_XinSiWeiLimitThrottleSpd(UWORD speedPWM);
  135. #endif
  136. /*---------------------------- file end -------------------------------------*/