canAppl.h 20 KB

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