canAppl.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. /**
  2. * @file canAppl.h
  3. * @author Zhang, Kai(zhangkai71@midea.com)
  4. * @brief
  5. * @version 0.1
  6. * @date 2022-03-02
  7. *
  8. * @copyright Copyright (c) 2022
  9. *
  10. */
  11. /************************************************************************
  12. Beginning of File, do not put anything above here except notes
  13. Compiler Directives:
  14. ************************************************************************/
  15. #ifndef CANAPPL_H
  16. #define CANAPPL_H
  17. #include "typedefine.h"
  18. #include "gd32f30x.h"
  19. #include "AssistCurve.h"
  20. /****************************************
  21. *
  22. * Definitions & Macros
  23. *
  24. ****************************************/
  25. #define CAN_MC_ALARMCODE_DEFAULT \
  26. { \
  27. 0x00000000 \
  28. }
  29. #define CAN_MC_ALARMCODE_CNT_RECORD_DEFAULT \
  30. { \
  31. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 \
  32. }
  33. #define ALAM_DETECT_CNT_IN_1ms 120000
  34. #define ALAM_DISPLAY_CNT_0LEVEL 1
  35. #define ALAM_DISPLAY_CNT_1LEVEL 3
  36. #define ALAM_DISPLAY_CNT_2LEVEL 10
  37. #define ALAM_DISPLAY_CNT_3LEVEL 30
  38. /***************************************
  39. *
  40. * Type Definations
  41. *
  42. ***************************************/
  43. typedef enum
  44. {
  45. MC_Cadence_Forward = 0x00,
  46. MC_Cadence_Backward = 0x01,
  47. MC_Cadence_Stop = 0x02
  48. } MC_CadenceDir_Struct_t;
  49. typedef enum
  50. {
  51. MC_LightSwitch_OFF = 0xF0,
  52. MC_LightSwitch_ON = 0xF1
  53. } MC_LightSwitch_Struct_t;
  54. /**
  55. * @brief 电机运行信息,占用空间32bytes
  56. *
  57. */
  58. typedef struct
  59. {
  60. uint16_t BikeSpeed; ///>车速 0.1km/h,地址偏移0
  61. int16_t MotorSpeed; ///>输出转速 1rpm,地址偏移2
  62. uint16_t Power; ///>电功率 1W,地址偏移4
  63. uint16_t BusVoltage; ///>母线电压 1mV,地址偏移6
  64. uint16_t BusCurrent; ///>母线电流 1mA,地址偏移8
  65. uint8_t Cadence; ///>踏频 1rpm,地址偏移10
  66. uint8_t Torque; ///>踩踏力矩 1Nm,地址偏移11
  67. MC_CadenceDir_Struct_t CadenceDir; ///>踩踏方向 0-正,1-反,2-停止,地址偏移12
  68. uint8_t GearSt; ///>助力档位,地址偏移13
  69. MC_LightSwitch_Struct_t LightSwitch; ///>灯开关 0xF0-关,0xF1-开,地址偏移14
  70. uint8_t SOC; ///>剩余电量 1%,地址偏移15
  71. uint16_t RemainDistance; ///>续航里程 1km,地址偏移16
  72. // uint8_t RS1[2];
  73. uint16_t ODO_Km; ///>总里程 1km,地址偏移18
  74. uint8_t PowerPerKm; ///>平均功耗 0.01Ah/km ,地址偏移20
  75. uint8_t T_PCB; ///>PCB温度 +40℃,地址偏移21
  76. uint8_t T_Coil; ///>绕组温度 +40℃,地址偏移22
  77. uint8_t T_MCU; ///>MCU温度 +40℃,地址偏移23
  78. uint16_t Ride_Km; ///>开机后骑行里程 0.1km, 地址偏移24
  79. uint16_t Ride_Time; ///>开机后骑行时间 1s,地址偏移26
  80. uint8_t RS2[4]; ///>预留 4bytes
  81. } MC_RunInfo_Struct_t;
  82. /**
  83. * @brief 电机故障码
  84. *
  85. */
  86. typedef union MC_ERRORCODE
  87. {
  88. struct
  89. {
  90. uint32_t Protect_OverCurrent : 1; ///>过流保护
  91. uint32_t Protect_UnderVoltage : 1; ///>低压保护
  92. uint32_t Protect_OverVoltage : 1; ///>过压保护
  93. uint32_t Protect_LockRotor : 1; ///>堵转保护
  94. uint32_t Protect_OverTemp : 1; ///>过热保护
  95. uint32_t Fault_BikeSpdSensor : 1; ///>车速传感器故障
  96. uint32_t Fault_TorqueSensor : 1; ///>力矩传感器故障
  97. uint32_t Fault_HallSensor : 1; ///>霍尔传感器故障
  98. uint32_t Fault_PhaseLine : 1; ///>相线故障
  99. uint32_t Fault_PCBNTC : 1; ///>PCB温度传感器故障
  100. uint32_t Fault_BMS_Check : 1; ///>BMS校验失败
  101. uint32_t reserve1 : 1; /// s
  102. // uint32_t Fault_HMI_Check :1;///>HMI校验失败
  103. uint32_t Fault_PBU_Check : 1; ///>PBU校验失败
  104. uint32_t Fault_MCU : 1; ///>MCU故障
  105. uint32_t Fault_CadenceSensor : 1; ///>踏频传感器故障
  106. uint32_t Fault_GasSensor : 1; ///>指拨故障
  107. uint32_t Fault_MOS : 1; ///>MOS短路
  108. uint32_t Protect_VoltageChange : 1; ///>电压波动异常
  109. uint32_t Fault_Circuit : 1; ///>电路故障
  110. uint32_t Fault_TE_MCU : 1; ///>TE MCU故障
  111. uint32_t Fault_TE_Circuit : 1; ///>TE 电路故障
  112. uint32_t Fault_MC_Check : 1; ///>MC校验失败
  113. uint32_t Fault_SpiPosSensor : 1; ///>SPI位置故障
  114. uint32_t Fault_Throttle : 1; ///>转把故障
  115. uint32_t RS1 : 1;
  116. uint32_t RS2 : 1;
  117. uint32_t RS3 : 1;
  118. uint32_t RS4 : 1;
  119. uint32_t RS5 : 1;
  120. uint32_t RS6 : 1;
  121. uint32_t RS7 : 1;
  122. uint32_t RS8 : 1;
  123. } ERROR_Bit;
  124. uint32_t Code;
  125. } MC_ErrorCode_Struct_t;
  126. /**
  127. * @brief 电机故障码
  128. *
  129. */
  130. typedef struct MC_ERROR_CNT_RECORD
  131. {
  132. uint32_t ulAlamCntTimeCnt_1ms;
  133. uint16_t Protect_OverCurrentCnt; ///>过流保护
  134. uint16_t Protect_UnderVoltageCnt; ///>低压保护
  135. uint16_t Protect_OverVoltageCnt; ///>过压保护
  136. uint16_t Protect_LockRotorCnt; ///>堵转保护
  137. uint16_t Protect_OverTempCnt; ///>过热保护
  138. uint16_t Fault_SpeedSensorCnt; ///>速度传感器故障
  139. uint16_t Fault_TorqueSensorCnt; ///>力矩传感器故障
  140. uint16_t Fault_HallSensorCnt; ///>霍尔传感器故障
  141. uint16_t Fault_PhaseLineCnt; ///>相线故障
  142. uint16_t Fault_NtcSensorCnt; ///>温度传感器故障
  143. uint16_t Fault_BMS_CheckCnt; ///>BMS校验失败
  144. // uint16_t Fault_HMI_Check :1;///>HMI校验失败
  145. uint16_t Fault_PBU_CheckCnt; ///>PBU校验失败
  146. uint16_t Fault_MCUCnt; ///>MCU故障
  147. uint16_t Fault_CadenceSensorCnt; ///>踏频传感器故障
  148. uint16_t Fault_GasSensorCnt; ///>指拨故障
  149. uint16_t Fault_MOSCnt; ///>MOS短路
  150. uint16_t Protect_VoltageChangeCnt; ///>电压波动异常
  151. uint16_t Fault_CircuitCnt; ///>电路故障
  152. uint16_t Fault_TE_MCUCnt; ///>TE MCU故障
  153. uint16_t Fault_TE_CircuitCnt; ///>TE 电路故障
  154. uint16_t Fault_MC_CheckCnt; ///>MC校验失败
  155. } MC_ErrorCode_CNT_RECORD_Struct_t;
  156. /**
  157. * @brief 在线检测结果,占用空间1byte
  158. *
  159. */
  160. typedef union ONLINE_STATUS
  161. {
  162. struct
  163. {
  164. uint8_t BMS_OffLine : 1; // BMS离线
  165. uint8_t PBU_OffLine : 1; // PBU离线
  166. uint8_t HMI_OffLine : 1; // HMI离线
  167. uint8_t RS1 : 1;
  168. uint8_t RS2 : 1;
  169. uint8_t RS3 : 1;
  170. uint8_t RS4 : 1;
  171. uint8_t RS5 : 1;
  172. } Status_Bit;
  173. uint8_t Status;
  174. } OnLine_Status_Struct_t;
  175. /**
  176. * @brief MC版本信息,占用空间64bytes
  177. *
  178. */
  179. typedef struct
  180. {
  181. char Mode[16]; ///>型号 ASCII,0x2E结束,无效填充0x20
  182. char SN_Num[16]; ///>序列号 ASCII,0x2E结束,无效填充0x20
  183. char HW_Version[16]; ///>硬件版本 ASCII,0x2E结束,无效填充0x20
  184. char FW_Version[16]; ///>软件版本 ASCII,0x2E结束,无效填充0x20
  185. } MC_VerInfo_Struct_t;
  186. /**
  187. * @brief MC生产信息,占用空间32bytes
  188. *
  189. */
  190. typedef struct
  191. {
  192. char Manufacturer[8]; ///>生产厂商 ASCII,0x2E结束,无效填充0x20
  193. char MacAddr[8]; ///>生产地 ASCII,0x2E结束,无效填充0x20
  194. char MacDate[8]; ///>生产日期 ASCII,0x2E结束,无效填充0x20
  195. char MacBrand[8];
  196. } MC_MacInfo_Struct_t;
  197. /**
  198. * @brief MC生产信息,占用空间32bytes
  199. *
  200. */
  201. typedef struct
  202. {
  203. char CustomASCII1[16]; ///>生产厂商 ASCII,0x2E结束,无效填充0x20
  204. char CustomASCII2[16]; ///>生产地 ASCII,0x2E结束,无效填充0x20
  205. char CustomASCII3[16]; ///>生产日期 ASCII,0x2E结束,无效填充0x20
  206. } MC_RS_ASCII_Struct_t;
  207. /**
  208. * @brief MC骑行历史信息,占用空间16bytes
  209. *
  210. */
  211. typedef struct
  212. {
  213. uint32_t ODO_Km; ///>ODO里程,地址偏移0
  214. uint32_t ODO_Time; ///>ODO时间,地址偏移4
  215. uint32_t TRIP_Km; ///>TRIP里程,地址偏移8
  216. uint32_t TRIP_Time; ///>TRIP时间,地址偏移12
  217. } MC_RideLog_Struct_t;
  218. /**
  219. * @brief BMS状态信息,占用空间1byte
  220. *
  221. */
  222. typedef union BMS_STATUS
  223. {
  224. struct
  225. {
  226. uint8_t Charge : 1; ///>充电
  227. uint8_t Discharge : 1; ///>放电
  228. uint8_t RS1 : 1;
  229. uint8_t RS2 : 1;
  230. uint8_t RS3 : 1;
  231. uint8_t RS4 : 1;
  232. uint8_t RS5 : 1;
  233. uint8_t RS6 : 1;
  234. } Status_Bit;
  235. uint8_t Status;
  236. } BMS_STATUS_Struct_t;
  237. /**
  238. * @brief 电池运行信息,占用空间16bytes
  239. *
  240. */
  241. typedef struct
  242. {
  243. uint16_t Voltage; ///>电压 1mV,地址偏移0
  244. uint16_t Current; ///>电流 1mA,地址偏移2
  245. uint16_t RC; ///>剩余容量 1mAh,地址偏移4
  246. uint16_t FCC; ///>满充容量 1mAh,地址偏移6
  247. uint8_t Cell_NTC; ///>电芯温度 +40℃,地址偏移8
  248. uint8_t SOC; ///>剩余电量 1%,地址偏移9
  249. BMS_STATUS_Struct_t Status; ///>运行状态,地址偏移10
  250. uint8_t RS[5];
  251. } BMS_RunInfo_Struct_t;
  252. /**
  253. * @brief 助力档位信息
  254. *
  255. */
  256. typedef enum
  257. {
  258. MC_GearSt_OFF = 0x00,
  259. MC_GearSt_Torque_ECO = 0x01,
  260. MC_GearSt_Torque_NORM = 0x02,
  261. MC_GearSt_Torque_SPORT = 0x03,
  262. MC_GearSt_Torque_TURBO = 0x04,
  263. MC_GearSt_SMART = 0x33,
  264. MC_GearSt_WALK = 0x22
  265. } MC_GearSt_Struct_t;
  266. /**
  267. * @brief 电机控制指令,占用空间2bytes
  268. *
  269. */
  270. typedef struct
  271. {
  272. MC_GearSt_Struct_t GearSt; ///>助力档位
  273. MC_LightSwitch_Struct_t LightSwitch; ///>灯开关 0xF0-关,0xF1-开
  274. } MC_ControlCode_Struct_t;
  275. /**
  276. * @brief 电机运行信息,占用空间32bytes
  277. *
  278. */
  279. typedef struct
  280. {
  281. uint8_t Torque; ///>踩踏力矩 1Nm,地址偏移0
  282. MC_CadenceDir_Struct_t CadenceDir; ///>踩踏方向 0-正,1-反,2-停止,地址偏移1
  283. uint8_t Cadence; ///>踏频 1rpm,地址偏移2
  284. uint8_t GearSt; ///>助力档位,地址偏移3
  285. uint8_t T_PCB; ///>PCB温度 +40℃,地址偏移4
  286. uint8_t T_Coil; ///>绕组温度 +40℃,地址偏移5
  287. uint16_t BusVoltage; ///>母线电压 1mV,地址偏移6
  288. uint16_t BusCurrent; ///>母线电流 1mA,地址偏移8
  289. int16_t MotorSpeed; ///>输出转速 1rpm,地址偏移10
  290. uint16_t BikeSpeed; ///>车速 0.1km/h,地址偏移12
  291. int16_t IqCurrent; ///> Iq电流反馈 1mA 地址偏移14
  292. uint8_t AlarmCode; ///> 故障码最多8个故障 地址偏移16
  293. uint8_t RS2; ///> 预留 地址偏移17
  294. } MC_RunInfoToCDL_Struct_t;
  295. /***************************************
  296. *
  297. * Host computer Type Definations
  298. *
  299. ***************************************/
  300. typedef struct
  301. {
  302. UWORD uwSaveFlg;
  303. UWORD uwPolePairs;
  304. UWORD uwRsmOhm;
  305. UWORD uwLduH;
  306. UWORD uwLquH;
  307. UWORD uwFluxmWb;
  308. UWORD uwIdMaxA;
  309. UWORD uwIdMinA;
  310. UWORD uwRSpdRpm;
  311. UWORD uwRPwrWt;
  312. UWORD uwRCurA;
  313. UWORD uwRVolV;
  314. UWORD uwJD;
  315. UWORD uwTorMaxNm;
  316. UWORD reserve1;
  317. UWORD reserve2;
  318. UWORD reserve3;
  319. UWORD reserve4;
  320. UWORD reserve5;
  321. UWORD reserve6;
  322. UWORD reserve7;
  323. UWORD reserve8;
  324. } UPC_MotorInfo_Struct_t;
  325. typedef struct
  326. {
  327. UWORD uwSaveFlg;
  328. UWORD uwWheelDiameter; //轮胎周长 cm
  329. UWORD uwMechRationMotor; //传动比 0.1
  330. UWORD uwAssistMaxSpdKmH; //限速 1km/h
  331. UWORD uwThrottleMaxSpdKmH; //推行模式限速 1km/h
  332. UWORD uwNmFrontChainring; //前牙盘 T
  333. UWORD uwNmBackChainring; //后牙盘 T
  334. UWORD uwAssistSelect1; //助力方案1
  335. UWORD uwAssistSelect2; //助力方案2
  336. UWORD uwLightVoltage; //灯压配置 6/12V
  337. SWORD swWheelSizeAdjust; //周长微调 ±10cm
  338. UWORD uwStartMode; //启动模式 1-柔和,2-正常,3-强劲
  339. UWORD uwAutoPowerOffTime; //自动关机时间 1min,0-不自动关机
  340. UWORD reserve1;
  341. } UPC_BikeInfo_Struct_t;
  342. typedef struct
  343. {
  344. UWORD uwSaveFlg;
  345. UWORD uwSPIPosOffsetOrigin;
  346. UWORD uwSPIPosOffsetNow;
  347. UWORD uwIPeakMaxA;
  348. UWORD uwAlamOCurA;
  349. UWORD uwAlamOVolV;
  350. UWORD uwAlamUVolV;
  351. UWORD uwAlamOverSpdRpm;
  352. UWORD uwAlamOverHeatCe;
  353. UWORD uwAlamRecHeatCe;
  354. UWORD uwPwrLimitStartCe;
  355. UWORD reserve1;
  356. UWORD reserve2;
  357. UWORD reserve3;
  358. UWORD reserve4;
  359. UWORD reserve5;
  360. UWORD reserve6;
  361. UWORD reserve7;
  362. UWORD reserve8;
  363. } UPC_MControlInfo_Struct_t;
  364. typedef struct
  365. {
  366. UWORD uwSaveFlg;
  367. UWORD uwTorSensorOffsetOrigin;
  368. UWORD uwTorSensorOffsetNow1;
  369. UWORD uwTorSensorOffsetNow2;
  370. UWORD uwTorSensorOffsetNow3;
  371. UWORD uwTorSensorOffsetNow4;
  372. UWORD uwBikeTorMaxNm;
  373. UWORD uwBikeTor1StepRealNm;
  374. UWORD uwBikeTor1StepADC;
  375. UWORD uwBikeTor2StepRealNm;
  376. UWORD uwBikeTor2StepADC;
  377. UWORD uwBikeTor3StepRealNm;
  378. UWORD uwBikeTor3StepADC;
  379. UWORD uwBikeTor4StepRealNm;
  380. UWORD uwBikeTor4StepADC;
  381. UWORD uwCadSensorPulseNm;
  382. UWORD uwBikeSpdSensorPulseNm;
  383. UWORD reserve1;
  384. UWORD reserve2;
  385. UWORD reserve3;
  386. UWORD reserve4;
  387. } UPC_SensorInfo_Struct_t;
  388. typedef struct
  389. {
  390. SWORD swTorqueCurveNum;
  391. SWORD swCadenceCurveNum;
  392. } UPC_CurveOrderInfo_Struct_t;
  393. typedef struct
  394. {
  395. UWORD uwSaveFlg;
  396. UWORD reserve0;
  397. UWORD swStartupGain;
  398. UWORD swStartcruiseGain;
  399. UPC_CurveOrderInfo_Struct_t stCurveOrderInfo;
  400. SLONG slTorquePolyA;
  401. SLONG slTorquePolyB;
  402. SLONG slTorquePolyC;
  403. SLONG slTorquePolyD;
  404. SLONG slCadencePolyA;
  405. SLONG slCadencePolyB;
  406. SLONG slCadencePolyC;
  407. SLONG slCadencePolyD;
  408. UWORD uwAssistStartNm;
  409. UWORD uwAssistStopNm;
  410. UWORD uwStartUpGainStep;
  411. UWORD uwStartUpCadNm;
  412. UWORD uwTorLPFCadNm;
  413. UWORD uwSpeedAssistSpdRpm;
  414. UWORD uwSpeedAssistIMaxA;
  415. UWORD uwAssistLimitBikeSpdStart;
  416. UWORD uwAssistLimitBikeSpdStop;
  417. UWORD uwCadenceAssistWeight;
  418. UWORD reserve1;
  419. UWORD reserve2;
  420. UWORD reserve3;
  421. UWORD reserve4;
  422. UWORD reserve5;
  423. UWORD reserve6;
  424. UWORD reserve7;
  425. UWORD reserve8;
  426. } UPC_AssistInfo_Struct_t;
  427. typedef struct
  428. {
  429. UWORD uwSaveFlg;
  430. UWORD uwOpenTimes;
  431. UWORD uwUsedTimeH;
  432. UWORD uwUsedTimeL;
  433. UWORD uwNTCTempMaxCe;
  434. UWORD uwNTCTempMinCe;
  435. UWORD uwAlamHOcurTimes;
  436. UWORD uwAlamSOcurTimes;
  437. UWORD uwAlamOHeatTimes;
  438. UWORD uwAlamRotorLockTimes;
  439. UWORD uwAlamPhsLossTimes;
  440. UWORD uwAlamOVolTimes;
  441. UWORD uwAlamUVolTimes;
  442. UWORD uwAlamComOTimeTimes;
  443. UWORD uwG1AvgPwrConsumption;
  444. UWORD uwG2AvgPwrConsumption;
  445. UWORD uwG3AvgPwrConsumption;
  446. UWORD uwG4AvgPwrConsumption;
  447. UWORD uwG5AvgPwrConsumption;
  448. UWORD uwODOTripH;
  449. UWORD uwODOTripL;
  450. UWORD uwODOTimeH;
  451. UWORD uwODOTimeL;
  452. UWORD uwTripSumH;
  453. UWORD uwTripSumL;
  454. UWORD uwTripSumTimeH;
  455. UWORD uwTripSumTimeL;
  456. UWORD uwTorSensorAlamTimes;
  457. UWORD uwCadSensorAlamTimes;
  458. UWORD uwBikeSpdSensorAlamTimes;
  459. UWORD uwPosSensorAlamTimes;
  460. UWORD reserve1;
  461. UWORD reserve2;
  462. UWORD reserve3;
  463. UWORD reserve4;
  464. UWORD reserve5;
  465. UWORD reserve6;
  466. UWORD reserve7;
  467. UWORD reserve8;
  468. } UPC_HistoryInfo_Struct_t;
  469. typedef struct
  470. {
  471. UWORD uwSaveFlg;
  472. UWORD uwEEFirstDefaultSetFlg;
  473. UWORD uwSPIOffsetFirstSetFlg;
  474. UWORD uwTestParaSaveFlg;
  475. UWORD RunModelSelect;
  476. UWORD ThetaGetModelSelect;
  477. UWORD CurrentSampleModelSelect;
  478. UWORD RotateDirectionSelect;
  479. UWORD uwInitPosCurAmp;
  480. UWORD uwVFControlVolAmp;
  481. UWORD uwIFControlCurAmp;
  482. UWORD uwVFIFTargetFreHz;
  483. UWORD uwSpeedLoopAccRate;
  484. UWORD uwSpeedLoopDecRate;
  485. UWORD uwSpeedLoopBandWidthHz;
  486. UWORD uwSpeedLoopCoefM;
  487. UWORD uwCuerrentLoopBandWidthHz;
  488. UWORD uwCurrentLoopCoefM;
  489. UWORD uwFluxObsBandWidthHz;
  490. UWORD uwFluxObsCoefM;
  491. UWORD uwThetaObsPLLBandWidthHz;
  492. UWORD uwThetaObsPLLCoefM;
  493. UWORD uwJm;
  494. UWORD uwPWMMaxDuty;
  495. UWORD uwPWM7to5Duty;
  496. UWORD uwPwrLimit;
  497. UWORD uwPwrLimitError;
  498. UWORD uwPwrLimitKp;
  499. UWORD uwPwrLimitKi;
  500. UWORD reserve1;
  501. UWORD reserve2;
  502. UWORD reserve3;
  503. UWORD reserve4;
  504. UWORD reserve5;
  505. UWORD reserve6;
  506. UWORD reserve7;
  507. UWORD reserve8;
  508. } UPC_TestParaInfo_Struct_t;
  509. typedef struct
  510. {
  511. UPC_MotorInfo_Struct_t stMotorInfo;
  512. UPC_BikeInfo_Struct_t stBikeInfo;
  513. UPC_MControlInfo_Struct_t stMContorlInfo;
  514. UPC_SensorInfo_Struct_t stSensorInfo;
  515. UPC_CurveOrderInfo_Struct_t stCurveOrderInfo;
  516. UPC_AssistInfo_Struct_t stAssistInfo;
  517. UPC_HistoryInfo_Struct_t stHistoryInfo;
  518. UPC_TestParaInfo_Struct_t stTestParaInfo;
  519. } MC_UpperPCInfo_Struct_t;
  520. typedef struct
  521. {
  522. uint8_t uwWheelDiameter; ///>车轮默认长度 1cm
  523. uint8_t StartUpMod; ///>1-柔和,2-正常,3-强劲,地址偏移1
  524. uint8_t BikeSpeedLimit; /// km/h
  525. int8_t DeltDiameter; ///>有符型,单位1cm,±10.0cm 1Nm,地址偏移0
  526. uint8_t AssistMod; ///>助力模式1-2,地址偏移2
  527. uint8_t AutoPowerOffTime;
  528. uint8_t reserve1;
  529. uint8_t reserve2;
  530. } OBC_SetCustomPara_Struct_t;
  531. //仪表按键状态
  532. typedef union OBC_BUTTON_STATU
  533. {
  534. struct
  535. {
  536. uint8_t Set : 1;
  537. uint8_t Light : 1;
  538. uint8_t Walk : 1;
  539. uint8_t Dec : 1;
  540. uint8_t Acc : 1;
  541. uint8_t Power : 1;
  542. uint8_t RS1 : 1;
  543. uint8_t RS2 : 1;
  544. } Status_Bit;
  545. uint8_t KeyStatus;
  546. } OBC_ButtonStatu_Struct_t;
  547. typedef struct
  548. {
  549. uint8_t Reserver;
  550. OBC_ButtonStatu_Struct_t ButtonStatu;
  551. ULONG ulButtonSetTimeCnt;
  552. } OBC_ButtonStatus_Struct_t;
  553. /****************************************
  554. *
  555. * Exported variable
  556. *
  557. ****************************************/
  558. extern MC_RunInfo_Struct_t MC_RunInfo;
  559. extern MC_ErrorCode_Struct_t MC_ErrorCode;
  560. extern MC_ErrorCode_CNT_RECORD_Struct_t MC_ErrorCntRecord;
  561. extern MC_VerInfo_Struct_t MC_VerInfo;
  562. extern MC_MacInfo_Struct_t MC_MacInfo;
  563. extern MC_RideLog_Struct_t MC_RideLog;
  564. extern BMS_RunInfo_Struct_t BMS_RunInfo;
  565. extern MC_ControlCode_Struct_t MC_ControlCode;
  566. extern MC_RunInfoToCDL_Struct_t MC_RunInfoToCDL;
  567. extern MC_RS_ASCII_Struct_t MC_RsASSCII;
  568. extern MC_UpperPCInfo_Struct_t MC_UpcInfo;
  569. extern OBC_SetCustomPara_Struct_t OBC_SetCustomPara;
  570. extern OBC_ButtonStatus_Struct_t OBC_ButtonStatus;
  571. extern ULONG ulOBC_ComTimeOutCount;
  572. extern uint8_t MC_MotorSPD_rpm_Percent;
  573. extern uint8_t MC_WorkMode;
  574. extern uint8_t MC_BC_COM;
  575. extern UWORD LightSwitch;
  576. extern ULONG ODO_T, TRIP_T;
  577. extern BOOL blFlashSaveflg;
  578. /************************************************************************
  579. Ram Allocation
  580. *************************************************************************/
  581. /***************************************
  582. *
  583. * Function Definations
  584. *
  585. ***************************************/
  586. /**
  587. * @brief MC_UpcInfo上电初始化
  588. *
  589. */
  590. void Can_voUpdateMC_UpcInfo(void);
  591. /**
  592. * @brief MC运行状态初始化
  593. *
  594. */
  595. void Can_voInitMC_Run(void);
  596. /**
  597. * @brief 1ms中的MC运行状态更新
  598. *
  599. */
  600. void Can_voMC_Run_1ms(void);
  601. /**
  602. * @brief 5ms中的MC运行状态更新
  603. *
  604. */
  605. void Can_voMC_Run_5ms(void);
  606. /**
  607. * @brief 200ms中的MCMC运行状态更新
  608. *
  609. */
  610. void Can_voMC_Run_200ms(void);
  611. /**
  612. * @brief 接收挡位指令
  613. *
  614. */
  615. void Can_GearSt_switch(void);
  616. /**
  617. * @brief 接收开关灯指令
  618. *
  619. */
  620. void Can_Light_switch(void);
  621. /**
  622. * @brief 里程计算
  623. *
  624. */
  625. void Can_Trip_Cal(void);
  626. /**
  627. * @brief 根据电池反馈计算续航里程
  628. *
  629. */
  630. void Can_RemainTrip_Cal(void);
  631. /**
  632. * @brief 根据电压估算电量
  633. *
  634. */
  635. void Can_SOC_Cal(void);
  636. /**
  637. * @brief 根据协议显示助力曲线
  638. *
  639. */
  640. void Can_AssistCoef_Read(UPC_CurveOrderInfo_Struct_t *order);
  641. /**
  642. * @brief 根据协议写入助力曲线
  643. *
  644. */
  645. void Can_AssistCoef_Write(UPC_CurveOrderInfo_Struct_t *order);
  646. #endif
  647. /************************************************************************
  648. End of this File (EOF)!
  649. Do not put anything after this part!
  650. ************************************************************************/