canAppl.h 20 KB

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