From f16825ea2b2e01564cce432456ea37edd3a24d12 Mon Sep 17 00:00:00 2001 From: caocong Date: Fri, 9 Jan 2026 19:16:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9:=E5=A4=9A=E8=81=94=E5=BC=80?= =?UTF-8?q?=E5=85=B3=E5=9C=BA=E6=99=AF=E6=89=A7=E8=A1=8C=E4=B8=AD=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=9B=9E=E8=B7=AF=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 多联开关场景执行中增加回路判断,删除部分调试信息 --- MCU_Driver/blv_authorize.c | 41 +++++++++++++++++++++++++++++++++ MCU_Driver/blv_dev_action.c | 16 ++++++++----- MCU_Driver/inc/blv_dev_action.h | 3 +-- User/main.c | 5 ++-- 4 files changed, 55 insertions(+), 10 deletions(-) diff --git a/MCU_Driver/blv_authorize.c b/MCU_Driver/blv_authorize.c index 4676229..f2373c4 100644 --- a/MCU_Driver/blv_authorize.c +++ b/MCU_Driver/blv_authorize.c @@ -9,6 +9,8 @@ #include "SPI_SRAM.h" #include "rw_logging.h" #include "sram_mem_addr.h" +#include "debug.h" +#include "rtc.h" #include BLV_AUTHORIZE sys_authorize; @@ -89,4 +91,43 @@ __attribute__((section(".non_0_wait"))) uint32_t Get_Authorize_UnixTime(void) return sys_authorize.expires_time; } +/******************************************************************************* +* Function Name : BLV_Authorize_Task +* Description : BLVȨ +*******************************************************************************/ +__attribute__((section(".non_0_wait"))) void BLV_Authorize_Task(void) +{ + static uint32_t sys_tick = 0; + uint32_t temp_unix = 0,curr_unix = 0; + + if(SysTick_1ms - sys_tick > 10000) + { + sys_tick = SysTick_1ms; + + Dbg_Println(DBG_BIT_SYS_STATUS_bit,"RTCʱ: 20%02X-%02X-%02X %02X:%02X:%02X %X",RTC_Raw_Data.year,RTC_Raw_Data.month,RTC_Raw_Data.day,RTC_Raw_Data.hour,RTC_Raw_Data.minute,RTC_Raw_Data.second,RTC_Raw_Data.week); + + temp_unix = RTC_Conversion_To_Unix(&RTC_Raw_Data); + + BLV_Authorize_Processing(temp_unix); + + if(Get_Authorize_Lock_Status() == 0x01) + { + Dbg_Println(DBG_BIT_SYS_STATUS_bit,"MCUȨ:%08X now:%08X-----",Get_Authorize_UnixTime(),temp_unix); + } + + /*в12ʱ䱣棬ʱ䱣浽Flash*/ + curr_unix = SRAM_Read_DW(SRAM_Register_Start_ADDRESS + Register_CurrentUsageTime_OFFSET); + if(temp_unix - curr_unix > 43200) + { + SRAM_Write_DW(temp_unix,SRAM_Register_Start_ADDRESS + Register_CurrentUsageTime_OFFSET); + Retain_Flash_Register_Data(); + } + } +} + + + + + + diff --git a/MCU_Driver/blv_dev_action.c b/MCU_Driver/blv_dev_action.c index b413f8f..5bd6933 100644 --- a/MCU_Driver/blv_dev_action.c +++ b/MCU_Driver/blv_dev_action.c @@ -3460,7 +3460,7 @@ __attribute__((section(".non_0_wait"))) void DevAction_DevAddr_Ctrl( /******************************************************************************* * @Function Name : BLV_DevDly_Process -* @Description : ʱ豸 +* @Description : ʱ豸 - * ʱ豸ִ: * 豸 * ִ @@ -3471,8 +3471,6 @@ __attribute__((section(".non_0_wait"))) void BLV_DevDly_Process(uint32_t dly_pro uint8_t KeepFlag = 0x00; Dev_Output_Ctrl_ptr Dev_Output_Ctrl; - Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"%s : %x",__func__,dly_processing_addr); - SRAM_DMA_Read_Buff((uint8_t *)&DevDlyInfo, sizeof(Struct_Dev_Dly), dly_processing_addr); if( (DevDlyInfo.DlyExcuteFlag == 0x01) && (SysTick_1ms >= DevDlyInfo.DlyExcuteTime) ) @@ -3484,6 +3482,7 @@ __attribute__((section(".non_0_wait"))) void BLV_DevDly_Process(uint32_t dly_pro if(DevDlyInfo.DevDlyCore.DevDlyAddr != 0x00) { + Device_Public_Information_G BUS_Public; switch(DevDlyInfo.DevDlyCore.DevType) { case Dev_Host_HVout: @@ -3509,10 +3508,14 @@ __attribute__((section(".non_0_wait"))) void BLV_DevDly_Process(uint32_t dly_pro case DEV_Carbon_Saved: case Dev_Energy_Monitor: Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"ʱ豸ִ:%d %d· : %X",DevDlyInfo.DevDlyCore.DevType, DevDlyInfo.DevDlyCore.DevOutputLoop ,DevDlyInfo.DevOutputType); - Dev_Output_Ctrl = (Dev_Output_Ctrl_ptr)SRAM_Read_DW(DevDlyInfo.DevDlyCore.DevDlyAddr + Dev_Output_Ctrl_0); - if(Dev_Output_Ctrl != NULL) + + if(BLV_Device_PublicInfo_Read_To_Struct(DevDlyInfo.DevDlyCore.DevDlyAddr,&BUS_Public) == 0x00) { - Dev_Output_Ctrl(0x00, 0x00, DevDlyInfo.DevDlyCore.DevDlyAddr, DevDlyInfo.DevDlyCore.DevOutputLoop, DevDlyInfo.DevOutputType); + Dev_Output_Ctrl = (Dev_Output_Ctrl_ptr)BUS_Public.DevFunInfo.Dev_Output_Ctrl; + if(Dev_Output_Ctrl != NULL) + { + Dev_Output_Ctrl(0x00, 0x00, DevDlyInfo.DevDlyCore.DevDlyAddr, DevDlyInfo.DevDlyCore.DevOutputLoop, DevDlyInfo.DevOutputType); + } } break; case Dev_Host_Invalid: @@ -3526,6 +3529,7 @@ __attribute__((section(".non_0_wait"))) void BLV_DevDly_Process(uint32_t dly_pro SRAM_DMA_Write_Buff((uint8_t *)&DevDlyInfo,sizeof(Struct_Dev_Dly),dly_processing_addr); } + //ִ˸ if( DevDlyInfo.DlyBlinkFlag == 0x01 ) { Dbg_Println(DBG_BIT_LOGIC_STATUS_bit,"ǰʱʱ˸ִ:%d %d· : %X",DevDlyInfo.DevDlyCore.DevType, DevDlyInfo.DevDlyCore.DevOutputLoop ,DevDlyInfo.DevOutputType); //̵״ֵ̬ diff --git a/MCU_Driver/inc/blv_dev_action.h b/MCU_Driver/inc/blv_dev_action.h index aebb342..64e9b52 100644 --- a/MCU_Driver/inc/blv_dev_action.h +++ b/MCU_Driver/inc/blv_dev_action.h @@ -247,9 +247,8 @@ typedef struct uint8_t DlyExcuteFlag; //ʱִб־ʱ־һ uint8_t DlyBlinkFlag; //ʱ˸־ʱ˸־һʱʱִб־һ ҲǶ־ 0Ϊ 1Ϊ ʱ ֱִ豸 uint16_t DevOutputType; //豸ͣ豸ִзʽִ - uint32_t DlyExcuteTime; //ʱִʱ䣬ʱʱ䱻ֵ + uint32_t DlyExcuteTime; //ִʱʱ䣬ʱʱ䱻ֵ Struct_Dev_Dly_Core DevDlyCore; //ʱ ؼϢ - Dev_Dly_Value DlyBlinkTime; //˸Ƶ 0201 Ϊ1Sл 0202 Ϊ2Sл Ϊ ΪǰҪִеչ豸± }Struct_Dev_Dly; //豸ʱṹ壬дʱչ豸 ̶16ֽ diff --git a/User/main.c b/User/main.c index 0e204f8..d7f6e26 100644 --- a/User/main.c +++ b/User/main.c @@ -30,9 +30,9 @@ int main(void) SystemCoreClockUpdate(); Systick_Init(); - UARTx_Init(UART_0,9600); //RS485ѯ˿ + UARTx_Init(UART_0,9600); //RS485ѯ˿ UARTx_Init(UART_1,512000); //Դ - UARTx_Init(UART_2,9600); //RS485˿ + UARTx_Init(UART_2,9600); //RS485˿ UARTx_Init(UART_3,115200); //BUS SYS_LED_Init(); @@ -49,6 +49,7 @@ int main(void) Dbg_Println(DBG_BIT_SYS_STATUS_bit,"DEV_ACTION_INFO Size:%d \r\n",sizeof(DEV_ACTION_INFO)); Dbg_Println(DBG_BIT_SYS_STATUS_bit,"Dev_Action_U64Cond Size:%d \r\n",sizeof(Dev_Action_U64Cond)); + Dbg_Println(DBG_BIT_SYS_STATUS_bit,"Struct_Dev_Dly Size:%d \r\n",sizeof(Struct_Dev_Dly)); BLV_DevAction_AllData_Init();