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();