zhunk 1 年之前
父节点
当前提交
df666bb55d

+ 0 - 2
Application_cbd_apm32f1/applications/beep.c

@@ -172,8 +172,6 @@ int hwtimer2_pwm3_output(rt_uint32_t time,rt_uint32_t freq,uint8_t EN,uint8_t DI
     rt_pin_mode(Motor_EN, PIN_MODE_OUTPUT);
     rt_pin_mode(Motor_DIR, PIN_MODE_OUTPUT);
     rt_pin_write(Motor_EN, EN);
-
-
     rt_pin_write(Motor_DIR, OFF);
 
     if(init_tim2()==0)

+ 1 - 1
Application_cbd_apm32f1/applications/control.h

@@ -33,7 +33,7 @@
     #define VERSION_HK_2000W    "1.3led.40(2000W)"       //水稻
 #else
     #define VERSION_HK          "2.5.41(HK)"            //4.0海康-1200W
-    #define VERSION_HK_2000W    "2.15.4(2000W)"         //4.0水稻
+    #define VERSION_HK_2000W    "2.16.4(2000W)"         //4.0水稻
 #endif
 
 #define VERSION_ZP          "1.45.1(ZP)"            //1.0转盘

+ 2 - 2
Application_cbd_apm32f1/applications/hmi.c

@@ -1558,12 +1558,12 @@ static void Ctr_Mortor_entry(void* parameter)
             ef_set_env_blob("run_sta", &device_status.run_sta, sizeof(device_status.run_sta));
          }
         else if (device_status.autotakepic==10) {
-            hwtimer2_pwm3_output(1,20000,1,0);
+            hwtimer2_pwm3_output(1,500000,1,0);
             device_status.autotakepic = 0;
         }
 
         else if (device_status.autotakepic==11) {
-            hwtimer2_pwm3_output(1,20000,1,1);
+            hwtimer2_pwm3_output(1,500000,1,1);
             device_status.autotakepic = 0;
         }
 

+ 55 - 49
Application_cbd_apm32f1/drivers/drv_rtc.c

@@ -14,13 +14,14 @@
 
 #ifdef BSP_USING_ONCHIP_RTC
 
-
+/*
 #ifndef HAL_RTCEx_BKUPRead
 #define HAL_RTCEx_BKUPRead(x1, x2) (~BKUP_REG_DATA)
 #endif
 #ifndef HAL_RTCEx_BKUPWrite
 #define HAL_RTCEx_BKUPWrite(x1, x2, x3)
 #endif
+*/
 #ifndef RTC_BKP_DR1
 #define RTC_BKP_DR1 RT_NULL
 #endif
@@ -29,63 +30,68 @@
 #define LOG_TAG             "drv.rtc"
 #include <drv_log.h>
 
-#define BKUP_REG_DATA 0xA5A5
+#define BKUP_REG_DATA 0xA0A0
 
 static struct rt_device rtc;
 
 static RTC_HandleTypeDef RTC_Handler;
-
+uint32_t           RTC_ReadTimeCounter(RTC_HandleTypeDef *hrtc);
+HAL_StatusTypeDef RTC_WriteTimeCounter(RTC_HandleTypeDef *hrtc, uint32_t TimeCounter);
 static time_t get_rtc_timestamp(void)
 {
-    RTC_TimeTypeDef RTC_TimeStruct = {0};
-    RTC_DateTypeDef RTC_DateStruct = {0};
-    struct tm tm_new;
-
-    HAL_RTC_GetTime(&RTC_Handler, &RTC_TimeStruct, RTC_FORMAT_BIN);
-    HAL_RTC_GetDate(&RTC_Handler, &RTC_DateStruct, RTC_FORMAT_BIN);
-
-    tm_new.tm_sec  = RTC_TimeStruct.Seconds;
-    tm_new.tm_min  = RTC_TimeStruct.Minutes;
-    tm_new.tm_hour = RTC_TimeStruct.Hours;
-    tm_new.tm_mday = RTC_DateStruct.Date;
-    tm_new.tm_mon  = RTC_DateStruct.Month - 1;
-    tm_new.tm_year = RTC_DateStruct.Year + 100;
-
-    LOG_D("get rtc time.");
-    return mktime(&tm_new);
+//    RTC_TimeTypeDef RTC_TimeStruct = {0};
+//    RTC_DateTypeDef RTC_DateStruct = {0};
+//    struct tm tm_new;
+//
+//    HAL_RTC_GetTime(&RTC_Handler, &RTC_TimeStruct, RTC_FORMAT_BIN);
+//    HAL_RTC_GetDate(&RTC_Handler, &RTC_DateStruct, RTC_FORMAT_BIN);
+//
+//    tm_new.tm_sec  = RTC_TimeStruct.Seconds;
+//    tm_new.tm_min  = RTC_TimeStruct.Minutes;
+//    tm_new.tm_hour = RTC_TimeStruct.Hours;
+//    tm_new.tm_mday = RTC_DateStruct.Date;
+//    tm_new.tm_mon  = RTC_DateStruct.Month - 1;
+//    tm_new.tm_year = RTC_DateStruct.Year + 100;
+//
+//    LOG_D("get rtc time.");
+//    RTC_ReadTimeCounter(&RTC_Handler);
+    //return mktime(&tm_new);
+    return RTC_ReadTimeCounter(&RTC_Handler);
 }
 
 static rt_err_t set_rtc_time_stamp(time_t time_stamp)
 {
-    RTC_TimeTypeDef RTC_TimeStruct = {0};
-    RTC_DateTypeDef RTC_DateStruct = {0};
-    struct tm *p_tm;
-
-    p_tm = localtime(&time_stamp);
-    if (p_tm->tm_year < 100)
-    {
-        return -RT_ERROR;
-    }
-
-    RTC_TimeStruct.Seconds = p_tm->tm_sec ;
-    RTC_TimeStruct.Minutes = p_tm->tm_min ;
-    RTC_TimeStruct.Hours   = p_tm->tm_hour;
-    RTC_DateStruct.Date    = p_tm->tm_mday;
-    RTC_DateStruct.Month   = p_tm->tm_mon + 1 ;
-    RTC_DateStruct.Year    = p_tm->tm_year - 100;
-    RTC_DateStruct.WeekDay = p_tm->tm_wday + 1;
-
-    if (HAL_RTC_SetTime(&RTC_Handler, &RTC_TimeStruct, RTC_FORMAT_BIN) != HAL_OK)
-    {
-        return -RT_ERROR;
-    }
-    if (HAL_RTC_SetDate(&RTC_Handler, &RTC_DateStruct, RTC_FORMAT_BIN) != HAL_OK)
-    {
-        return -RT_ERROR;
-    }
-
-    LOG_D("set rtc time.");
-    HAL_RTCEx_BKUPWrite(&RTC_Handler, RTC_BKP_DR1, BKUP_REG_DATA);
+//    RTC_TimeTypeDef RTC_TimeStruct = {0};
+//    RTC_DateTypeDef RTC_DateStruct = {0};
+//    struct tm *p_tm;
+//
+//    p_tm = localtime(&time_stamp);
+//    if (p_tm->tm_year < 100)
+//    {
+//        return -RT_ERROR;
+//    }
+//
+//    RTC_TimeStruct.Seconds = p_tm->tm_sec ;
+//    RTC_TimeStruct.Minutes = p_tm->tm_min ;
+//    RTC_TimeStruct.Hours   = p_tm->tm_hour;
+//    RTC_DateStruct.Date    = p_tm->tm_mday;
+//    RTC_DateStruct.Month   = p_tm->tm_mon + 1 ;
+//    RTC_DateStruct.Year    = p_tm->tm_year - 100;
+//    RTC_DateStruct.WeekDay = p_tm->tm_wday + 1;
+//
+//    if (HAL_RTC_SetTime(&RTC_Handler, &RTC_TimeStruct, RTC_FORMAT_BIN) != HAL_OK)
+//    {
+//        return -RT_ERROR;
+//    }
+//    if (HAL_RTC_SetDate(&RTC_Handler, &RTC_DateStruct, RTC_FORMAT_BIN) != HAL_OK)
+//    {
+//        return -RT_ERROR;
+//    }
+//
+//    LOG_D("set rtc time.");
+     HAL_RTCEx_BKUPWrite(&RTC_Handler, RTC_BKP_DR1, BKUP_REG_DATA);
+//    return RT_EOK;
+    RTC_WriteTimeCounter(&RTC_Handler,time_stamp);
     return RT_EOK;
 }
 
@@ -247,6 +253,6 @@ int rt_hw_rtc_init(void)
     LOG_D("rtc init success");
     return RT_EOK;
 }
-INIT_DEVICE_EXPORT(rt_hw_rtc_init);  //INIT_DEVICE_EXPORT
+INIT_APP_EXPORT(rt_hw_rtc_init);
 
 #endif /* BSP_USING_ONCHIP_RTC */

+ 1 - 0
Application_cbd_apm32f1/readme.md

@@ -1,3 +1,4 @@
+修复RTC问题
 # 2025-05-22 更新说明
 #define VERSION_HK_2000W    "2.15.4(2000W)"         //4.0水稻
 1. 修复偶发灯管状态显示异常问题,原因是和开关灯管状态的变量lamp_status冲突导致,解决:灯管状态使用单独的变量:lamp;