123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- /* includes ----------------------------------------------------------*/
- #include "global.h"
- /* typedef -----------------------------------------------------------*/
- /* define ------------------------------------------------------------*/
- /* macro -------------------------------------------------------------*/
- /* variables ---------------------------------------------------------*/
- global_par s_global_par;
- /* function prototypes -----------------------------------------------*/
- /**
- * @brief 中控板初始化
- * @param p_param_boot : 参数区指针
- * @param p_rs485RecDate:485接收数据区的指针
- * @note NONE
- * @retval 无
- */
- void centralCtrSys_Init(param_boot *p_param_boot, global_par *p_global_par){
- static uint16_t timeOutCnt = 0; // 超时计数
- uint8_t recBack = 0;
- uint16_t timeOutNum = 60000;
- rs485RecDate *p_rs485RecDate = &s_rs485RecDate;
- // 1. 从flash中读出VIN
- Read_ParamArea(); // 读出参数区的所有数据
- // 2. 与车通信获取vin数据(读取所有寄存器的值)
- modbus_read_holding_registers(0x01, 0x0000, 67);
- while(s_comData.vinRecSuccess != 1){
- if(timeOutCnt < timeOutNum){
- timeOutCnt++;
- }else{
- timeOutCnt = timeOutNum;
- break; // 未成功获取到车辆数据
- }
- }
- // 3. vin码比对
- if(s_comData.vinRecSuccess == 1){ // 成功获取到车辆数据
- if(memcmp(p_param_boot->vin, p_rs485RecDate->VIN, 26) != 0){ // 比对不成功
- // 备份新的VIN码
- memcpy(p_param_boot->vin, p_rs485RecDate->VIN, 26);
- Write_paramArea();
- // 置位中控板迁移事件
- BIT_SET(p_global_par->ctrEvent, CtrlPanelMigration);
- }
- }
- // 4. 初始化4g模块 4g模块在这里不好处理 放在任务中,围栏数据也一样
- // 5. 读取96位(或者说是3个32位的字)的唯一ID
- GetUniqueID(s_messageDate.devId);
- // 6. 陀螺仪的初始化
- recBack = atk_ms6050_init();
- if(recBack != 0){
- printf("ATK-MS6050 init failed!\r\n");
- BIT_SET(s_comData.Malfunction, gyroscope); // 置位陀螺仪数据异常故障
- }
- printf("ATK-MS6050 init\r\n");
-
- recBack = atk_ms6050_dmp_init();
- if(recBack != 0){
- printf("ATK-MS6050 DMP init failed!\r\n");
- BIT_SET(s_comData.Malfunction, gyroscope); // 置位陀螺仪数据异常故障
- }
- printf("ATK-MS6050 DMP init!\r\n");
- }
|