uart_TORG4BBSensor.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /**
  2. ******************************************************************************
  3. * @file uart_TORG4BBSensor.h
  4. * @author
  5. * @version V1.0.0
  6. * @date 05-02-2025
  7. * @brief TORG4BBSensor 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_TORG4BBSENSOR_H
  39. #define __UART_TORG4BBSENSOR_H
  40. /* Includes ------------------------------------------------------------------*/
  41. #include "usart.h"
  42. #define TORG4BBTORQU_ENABLE 1
  43. #define TORG4BBCADENCE_LPF_GAIN 80
  44. #define TORG4BBTORQUE_TIMEOUT_UNIT 10 //ms
  45. #define TORG4BBTORQUE_TIMEOUT_TIME 100 //ms
  46. #define TORG4BBTORQUE_NUMBERS_PULSES 9 //一周9个磁石
  47. /* Define to variables declare---------------------------------------------------*/
  48. //先发送低位后高位
  49. typedef struct
  50. {
  51. SWORD swTemp;//温度
  52. UWORD uwTorqueReg;//力矩
  53. UWORD uwTorqueRegLast;//力矩last
  54. UBYTE ucForwardCnt; //踏频脉冲
  55. UBYTE ucForwardCntLast; //踏频脉冲last
  56. UWORD uwFlyWheelSpeedCnt;//后飞轮电机转速Cnt
  57. UWORD uwFlyWheelSpeed;//后飞轮转速rpm
  58. } TORG4BBInfo_Struct_t;
  59. typedef struct
  60. {
  61. UWORD uwTorqueRegOffset;//力矩零点
  62. UWORD uwTorqueReg2Pu;
  63. UWORD uwTorqueLPFgain;
  64. UWORD uwMaxTimeOutCnt;
  65. UWORD uwTimeOutCnt;
  66. UWORD uwTorquePu;//力矩
  67. UWORD uwTorqueLPFPu;
  68. UWORD uwTorqueLPFPuLast;
  69. } TORG4BB_OUT;
  70. /* Public variables declare---------------------------------------------------*/
  71. extern TORG4BBInfo_Struct_t stTORG4BBInfo;
  72. /*Private function declare---------------------------------------------------*/
  73. void TORG4BB_Init(void);
  74. void TORG4BB_USART_DataProcess(USART_Buf_TypeDef* ptUartTx, UBYTE* Data);
  75. void TORG4BB_USART_RxData_Process(USART_Buf_TypeDef* ptUartTx, UBYTE* buf, UWORD dataCount);
  76. void TORG4BB_Torque_Handler(void);
  77. uint32_t TORG4BB_Get_CAD_PORT(void);
  78. SWORD TORG4BB_Get_Temp(void);
  79. #endif
  80. /*---------------------------- file end -------------------------------------*/