canAppl.h 20 KB

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