yf_zjb 3 лет назад
Родитель
Сommit
702a0cc33d

BIN
Application_CBD/Debug/Application_CBD.bin


BIN
Application_CBD/Debug/Application_CBD.elf


Разница между файлами не показана из-за своего большого размера
+ 1111 - 1116
Application_CBD/Debug/Application_CBD.map


BIN
Application_CBD/Debug/applications/beep.o


BIN
Application_CBD/Debug/applications/control.o


BIN
Application_CBD/Debug/applications/dtu_uart2.o


BIN
Application_CBD/Debug/applications/hmi.o


BIN
Application_CBD/Debug/applications/main.o


BIN
Application_CBD/Debug/applications/sample_mb_master.o


BIN
Application_CBD/Debug/applications/sht30_collect.o


BIN
Application_CBD/Debug/rt-thread/src/kservice.o


BIN
Application_CBD/Debug/rtthread.rbl


+ 4 - 2
Application_CBD/applications/control.c

@@ -2420,8 +2420,10 @@ static void Work_status_thread_entry(void *parameter)
      }
      while(1)
      {
-        WorkCheck();
-        rt_thread_delay(1);
+        if(device_status.ds==0){
+            WorkCheck();
+        }
+        rt_thread_delay(10);
      }
 }
 /*入口函数-工作流程*/

+ 13 - 5
Application_CBD/applications/control.h

@@ -19,22 +19,25 @@
 #define ROBOT_EN         0              //机器人
 #define Color_EN         0              //定制色诱
 #define BZYV2_EN         0              //孢子仪2.0
+#define BOOT_ERR         1              //1-新bootloader,0-旧bootloader()2023年9月份之前的设备升级需要设置为0
 ////////////////////////////////////////////////////////////////
 #if LAMP_EN == 1
     #define VERSION_HK          "1.(3ledv6).41(HK)" //4.0海康-三色光源
 #else
-    #define VERSION_HK          "1.49.41(HK)"       //4.0海康-1200W
+    #define VERSION_HK          "1.51.41(HK)"       //4.0海康-1200W
 #endif
-#define VERSION_HK_4800W    "1.48.48(HK)"       //4.0海康-4800W
-#define VERSION_HK_2000W    "1.46.4(2000W)"         //4.0水稻
-#define VERSION_ZP          "1.41.1(ZP)"            //1.0转盘
-#define VERSION_GK          "1.38.1(GK)"            //1.0高空
+#define VERSION_HK_4800W    ""                      //4.0海康-4800W
+#define VERSION_HK_2000W    "1.48.4(2000W)"         //4.0水稻
+#define VERSION_ZP          "1.43.1(ZP)"            //1.0转盘
+#define VERSION_GK          "1.40.1(GK)"            //1.0高空
 #define VERSION_XCT         "1.13.6(HK)"            //吸虫塔-海康
 #define VERSION_V5          "1.2.5(HK)"             //5.0
 #define VERSION_Robot       "1.0(robot)"            //展厅机器人
 
 #define VERSION_BZY         "2.5"                   //孢子仪
 
+
+
 #define CompileTime         rt_sprintf(device_status.driver_compile,"%s-%s",__DATE__,__TIME__)              //编译时间,每次更新代码修改
 /*********************************************************************/
 typedef struct  _packed
@@ -107,6 +110,10 @@ typedef struct  _packed
     uint8_t account_status;         //卡状态
     uint8_t test_flag;              //测试标志
     uint8_t sensor_485_sta;         //485传感器
+    #if BOOT_ERR == 1
+    uint8_t gps_inuse;
+    uint8_t gps_view;
+    #endif
     uint16_t dattim;         //数据上传间隔
     uint16_t shake_sec;      //震动时间
     uint16_t thsp;           //息屏时间
@@ -123,6 +130,7 @@ typedef struct  _packed
     char net[8];               //网络
     char sim[8];               //SIM卡
     char gps[8];               //定位类型
+    char gps_state[8];         //定位类型
     char tempture[12];         //温度
     char humidity[12];         //湿度
     char driver[64];           //版本

+ 17 - 4
Application_CBD/applications/dtu_uart2.c

@@ -322,7 +322,7 @@ int dtu_data_play(void)
                                     dtu_thread_entry_send,RT_NULL,
                                     DTU_THREAD_STACK_SIZE,
                                     3,                              //优先级高是为了保证数据上传的频率的精确度
-                                    DTU_THREAD_TIMESLICE
+                                    20          //时间片
             );
     /* 创建线程-指令接收解析*/
     dtu_recv_data = rt_thread_create("DTU_Uart_thread_recv",
@@ -468,7 +468,7 @@ char * makeJson()
     if(device_status.gps==NULL)
     rt_sprintf(device_status.gps, "0");
     //如果设备工作并且电流小于500,并且不是上电启动灯管异常
-    if(atoi(device_status.power)<400&&device_status.work_status==1&&makejson_sta!=0)
+    if(atoi(device_status.power)<400&&atoi(device_status.power)!=0&&device_status.work_status==1&&makejson_sta!=0)
     {
         #if LAMP_EN == 0
         LOG_I("Current is:%d",atoi(device_status.power));
@@ -1053,6 +1053,8 @@ int parseDtu(char *json_string)
                   mqttcfg1 = cJSON_GetObjectItem(item_ext,"mqttcfg1");
                   mqttcfg2 = cJSON_GetObjectItem(item_ext,"mqttcfg2");
                   link_sta = cJSON_GetObjectItem(item_ext,"link_sta");
+                  cJSON *gps_inuse = cJSON_GetObjectItem(item_ext,"gps_inuse");
+                  cJSON *gps_view = cJSON_GetObjectItem(item_ext,"gps_view");
                   //如果DTU的IMEI和FLash中的不一样,保存到FLASH
                   value_commn = cJSON_GetObjectItem(item_ext,"photo_sta");
                   if(value_commn!=RT_NULL)
@@ -1165,6 +1167,17 @@ int parseDtu(char *json_string)
                       rt_sprintf(device_status.gps,"%s",gps->valuestring);
                       if(atoi(gps->valuestring)!=0)
                       {
+                          #if BOOTERR == 1
+                           if(atoi(gps->valuestring)==1)
+                           rt_sprintf(device_status.gps_state, "%s","GPS+BD");
+
+                          if(gps_inuse!=NULL){
+                              device_status.gps_inuse = atoi(gps_inuse->valuestring);
+                          }
+                          if(gps_view!=NULL){
+                              device_status.gps_view = atoi(gps_view->valuestring);
+                          }
+                          #endif
                           if(strstr(device_status.lat,lat->valuestring)==NULL)
                           {
                               memset(device_status.lat,0,sizeof(device_status.lat));
@@ -1192,8 +1205,8 @@ int parseDtu(char *json_string)
                       memset(device_status.lng,0,sizeof(device_status.lng));
                       if(sizeof(device_status.lat)<3)
                       {
-                          sprintf(device_status.lat,"%s","34.8088073");
-                          sprintf(device_status.lng,"%s","113.6624298");
+                          sprintf(device_status.lat,"%s","0");
+                          sprintf(device_status.lng,"%s","0");
                       }
                       else {
                           sprintf(device_status.lat,"%s",lat->valuestring);

+ 8 - 24
Application_CBD/applications/hmi.c

@@ -120,29 +120,6 @@ static rt_err_t uart_input(rt_device_t dev, rt_size_t size)
     return result;
 }
 
-void bubblesort(int a[], int n)
-{
-    int temp, i, j, flag, k;
-    for(j = n - 1; j > 1; j--)
-    {
-        flag = 0;
-        for(i = 0; i < j; i++)
-        {
-            if(a[i] > a[i+1])
-            {
-                flag = 1;
-                temp = a[i];
-                a[i] = a[i+1];
-                a[i+1] = temp;
-            }
-        }
-        if(flag == 0)
-        {
-            // 如果这次子排序没有发生元素交换,则冒泡排序结束。
-            break;
-        }
-    }
-}
 
 /*入口函数*/
 static void Hmi_thread_entry(void *parameter)
@@ -297,6 +274,13 @@ static void HMI_Decode(void)
         if(device_status.thsp<60) device_status.thsp = device_status.thsp * 60;
         HMI_WRITE("thsp=%d",device_status.thsp);
         }
+        #if BOOTERR == 1
+        if(atoi(device_status.gps)==1){
+            HMI_WRITE("menu.gps_state.txt=\"定位成功:(%s)%d/%d\"",device_status.gps_state,device_status.gps_inuse,device_status.gps_view);
+        }else if(atoi(device_status.gps)==2){
+            HMI_WRITE("menu.gps_state.txt=\"定位成功:(基站)\"");
+        }
+        #endif
         //更新联网状态
         if(atoi(device_status.net)==1)
         {
@@ -1108,7 +1092,7 @@ static void HMI_Decode(void)
         if(device_status.version_type != 11)
         {
             device_status.version_type = 11;
-            sprintf(device_status.driver, "%s",VERSION_ZP);
+            sprintf(device_status.driver, "%s",VERSION_GK);
             ef_set_env_blob("version_type",&device_status.version_type,sizeof(device_status.version_type));        //版本类型
             ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype));        //版本类型
             MA_save();

+ 21 - 6
Application_CBD/applications/sht30_collect.c

@@ -152,9 +152,7 @@ static void Power_ReadCheck(void *parameter)
     int RV;
     while(1)
     {
-        #if ROBOT_EN == 0
-        sprintf(device_status.power,"%.2f",Read_Real_Current()/100.0*2.5);
-        #endif
+        sprintf(device_status.power,"%.2f",(float)Read_Real_Current()/100*2.5);
         if (Read_Real_Voltage()/100<12) {
                     //关闭外设
                     ctr_photo(OFF); //关闭相机供电
@@ -231,7 +229,7 @@ static void Power_ReadCheck(void *parameter)
                 }
             }
             //雨控
-            if(Read_Rain_Voltage()>100)
+            if(Read_Rain_Voltage()>1500)
             {
                 device_status.rain_status = 1;
                 ctr_lamp(OFF,1);
@@ -243,7 +241,7 @@ static void Power_ReadCheck(void *parameter)
                 rain_cnt++;
                 //雨控消抖,1分钟
                 LOG_D("rain_cnt:%d-value:%d",rain_cnt,Read_Rain_Voltage());
-                if(rain_cnt==60&&Read_Rain_Voltage()<100)
+                if(rain_cnt==60&&Read_Rain_Voltage()<1500)
                 {
                     rain_cnt = 0;
                     device_status.rain_status = 0;
@@ -278,8 +276,23 @@ int Read_Real_Current(void)
     rt_adc_disable(adc_dev, ADC_DEV_CHANNLE_1);
     //rt_adc_disable(adc_dev, 17);
     //rt_kprintf("read in adc:ADC17:%d-ADC1:%d\n",in_adc_17,adc1_value);
+    //return  (int)((ADC_VOL_BASE * (adc1_value*1.0)/(in_adc_17*1.0))*100000/250.0);
     return  (int)((ADC_VOL_BASE * (adc1_value*1.0)/(in_adc_17*1.0))*100000);
+    //INA293B:I = Vadc / (Rsense * Gain) = 0.0952V / (0.02 * 50) = 0.0952V / 1
+    #if INA293B2 == 1
+    return  (int)((ADC_VOL_BASE * (adc1_value*1.0)/(in_adc_17*1.0))*1000);  //扩大1000倍,把A转换为mA       50*? = 250   R = 0.5欧
+    #endif
 }
+/*
+ * https://blog.csdn.net/loop222/article/details/120497425
+采样电阻0.01 Ω
+运放为INA240A2,放大倍数50
+背面需分别短接A0/A2至输出
+C1_OUT=INA_VCC/2 + 0.01 * I * 50
+如果INA_VCC=3.3V,C1_OUT=1.65 + 0.01 * I * 50,电流范围(-3.3A,3.3A)
+如果INA_VCC=5.0V,C1_OUT=2.50 + 0.01 * I * 50,电流范围(-5A,5A)
+B相采样输入在PCB上为走线方便做了反向输入,所以放大倍数需乘以 -1(移植后的代码已经做了处理)
+*/
 /*读取电压值*/
 int Read_Real_Voltage(void)
 {
@@ -292,7 +305,9 @@ int Read_Real_Voltage(void)
     }
     HAL_ADCEx_Calibration_Start(adc_dev->parent.user_data);
     rt_adc_enable(adc_dev, ADC_DEV_CHANNLE_0);
-    adc0_value = rt_adc_read(adc_dev, ADC_DEV_CHANNLE_0);
+
+    //adc0_value = rt_adc_read(adc_dev, ADC_DEV_CHANNLE_0);
+    adc0_value = filter_Mid(rt_adc_read(adc_dev, ADC_DEV_CHANNLE_0));
     /* 关闭通道 */
     rt_adc_disable(adc_dev, ADC_DEV_CHANNLE_0);
     return  (adc0_value * REFER_VOLTAGE/CONVERT_BITS*12+20);

+ 4 - 1
Application_CBD/applications/sht30_collect.h

@@ -10,7 +10,7 @@
 #ifndef APPLICATIONS_INC_SHT30_COLLECT_H_
 #define APPLICATIONS_INC_SHT30_COLLECT_H_
 #define ADC_VOL_BASE                            1.20 //ADC内部电压基准,后续版本可改为针对每一块板子实际测量后写入 flash
-#define N 10        //adc采样计算次数
+#define N 11        //adc采样计算次数
 #define UART_485 "uart5"  /*串口设备名称*/
 
 
@@ -29,3 +29,6 @@ short Get_Temprate(void);
 unsigned int filter_Mid(int adc_return);
 unsigned int filter_voltage(void);
 #endif /* APPLICATIONS_INC_SHT30_COLLECT_H_ */
+
+//STM32之ADC(内部基准电压,参考电压)
+//https://www.cnblogs.com/jieruishu/p/9023811.html

+ 1 - 1
Application_CBD/packages/ota_downloader-latest/tools/ota_packager/rt_ota_packaging_tool.exe.config

@@ -6,5 +6,5 @@
   <runtime>
     <enforceFIPSPolicy enabled="false" />
   </runtime>
-  <configs SELEFILE="D:\RT-ThreadStudio\workspace\IOT_CBD_BZY_CTRL\Application_CBD\Debug\Application_CBD.bin" SAVEFILE="D:\RT-ThreadStudio\workspace\IOT_CBD_BZY_CTRL\Application_CBD\Debug\Application_CBD.rbl" COMPRESS="1" CRYPT="1" KEY="0123456789ABCDEF0123456789ABCDEF" IV="0123456789ABCDEF" NAME="app" VERSION="2.3" />
+  <configs SELEFILE="D:\RT-ThreadStudio\workspace\IOT_CBD_BZY_CTRL\Application_CBD\Debug\Application_CBD.bin" SAVEFILE="D:\RT-ThreadStudio\workspace\IOT_CBD_BZY_CTRL\Application_CBD\Debug\rtthread.rbl" COMPRESS="1" CRYPT="1" KEY="0123456789ABCDEF0123456789ABCDEF" IV="0123456789ABCDEF" NAME="app" VERSION="2.3" />
 </configuration>

+ 8 - 0
Application_CBD/readme.md

@@ -1,3 +1,11 @@
+# 2023-9-01 更新说明
+#define VERSION_HK          "1.50.41(HK)"       //4.0海康-1200W
+#define VERSION_HK_2000W    "1.47.4(2000W)"         //4.0水稻
+#define VERSION_ZP          "1.42.1(ZP)"            //1.0转盘
+#define VERSION_GK          "1.40.1(GK)"            //1.0高空
+#define VERSION_BZY         "2.6"                   //孢子仪
+1. 修复json下发孢子仪多段定时错误问题;
+
 # 2023-6-20 更新说明
 #define VERSION_HK          "1.49.41(HK)"       //4.0海康-1200W
 #define VERSION_HK_2000W    "1.46.4(2000W)"         //4.0水稻

BIN
CBD_FOTA_BootLoader/.settings/.rtmenus


+ 2 - 2
CBD_FOTA_BootLoader/applications/main.c

@@ -33,8 +33,8 @@
 #include "sys_config.h"
 #include <easyflash.h>
 
-#define BL_VERSION "1.1.3"
-#define COMPILE "20210701"
+#define BL_VERSION "1.1.4"
+#define COMPILE "20230901"
 
 #define RTU_DTU GET_PIN(B,13)
 #define Beep    GET_PIN(B, 4)

+ 3 - 0
CBD_FOTA_BootLoader/readme.md

@@ -1,4 +1,7 @@
 # 版本说明
+#define BL_VERSION "1.1.4"
+#define COMPILE "20230901"
+- 1. rt_fota.c中880行增加__set_CONTROL(0);
 ## VERSION "1.1.1"
 - 增加BL版本号和编译日期保存至EASYFLASH
 - main函数增加easyflash_init();