93 lines
3.0 KiB
C
93 lines
3.0 KiB
C
/*
|
||
* blv_authorize.c
|
||
*
|
||
* Created on: Nov 8, 2025
|
||
* Author: cc
|
||
*/
|
||
#include "blv_authorize.h"
|
||
|
||
#include "SPI_SRAM.h"
|
||
#include "rw_logging.h"
|
||
#include "sram_mem_addr.h"
|
||
#include <string.h>
|
||
|
||
BLV_AUTHORIZE sys_authorize;
|
||
|
||
/*******************************************************************************
|
||
* Function Name : BLV_Set_Authorize_Status
|
||
* Description : 设置BLV系统授权状态
|
||
* Input :
|
||
expires_time :授权时间
|
||
* Return : None
|
||
*******************************************************************************/
|
||
__attribute__((section(".non_0_wait"))) void BLV_Set_Authorize_Status(uint32_t Expires_time,uint8_t lock)
|
||
{
|
||
memset(&sys_authorize,0,sizeof(BLV_AUTHORIZE));
|
||
|
||
sys_authorize.lock_status = lock;
|
||
sys_authorize.expires_time = Expires_time;
|
||
}
|
||
|
||
/*******************************************************************************
|
||
* Function Name : BLV_Authorize_Processing
|
||
* Description : BLV系统授权处理
|
||
* Input :
|
||
utc_time :运行utc时间
|
||
* Return : None
|
||
*******************************************************************************/
|
||
__attribute__((section(".non_0_wait"))) void BLV_Authorize_Processing(uint32_t utc_time)
|
||
{
|
||
uint32_t temp_tick = utc_time;
|
||
uint32_t temp_lock = 0;
|
||
if((sys_authorize.expires_time != 0x00) && (temp_tick >= sys_authorize.expires_time ) )
|
||
{
|
||
sys_authorize.lock_status = 1;
|
||
/*检测到时间到期后,将锁定状态置位,同时保存到Flash中*/
|
||
temp_lock = SRAM_Read_DW(SRAM_Register_Start_ADDRESS + Register_MandateLock_OFFSET);
|
||
if(temp_lock != 0x00000001)
|
||
{
|
||
SRAM_Write_DW(0x01,SRAM_Register_Start_ADDRESS + Register_MandateLock_OFFSET);
|
||
//Retain_Flash_Register_Data();
|
||
}
|
||
}
|
||
}
|
||
|
||
/*******************************************************************************
|
||
* Function Name : Get_Authorize_Lock_Status
|
||
* Description : 获取授权锁定状态
|
||
* Input :
|
||
0x00:当前授权未锁定
|
||
0x01:当前授权锁定
|
||
*******************************************************************************/
|
||
__attribute__((section(".non_0_wait"))) void Set_Authorize_Lock_Status(uint8_t state)
|
||
{
|
||
sys_authorize.lock_status = state;
|
||
}
|
||
|
||
/*******************************************************************************
|
||
* Function Name : Get_Authorize_Lock_Status
|
||
* Description : 获取授权锁定状态
|
||
* Input : None
|
||
* Return :
|
||
0x00:当前授权未锁定
|
||
0x01:当前授权锁定
|
||
*******************************************************************************/
|
||
__attribute__((section(".non_0_wait"))) uint8_t Get_Authorize_Lock_Status(void)
|
||
{
|
||
if(sys_authorize.expires_time != 0x00) return sys_authorize.lock_status;
|
||
return 0x00;
|
||
}
|
||
|
||
/*******************************************************************************
|
||
* Function Name : Get_Authorize_UnixTime
|
||
* Description : 获取授权锁定时间戳
|
||
* Input : None
|
||
* Return : 授权锁定时间戳
|
||
*******************************************************************************/
|
||
__attribute__((section(".non_0_wait"))) uint32_t Get_Authorize_UnixTime(void)
|
||
{
|
||
return sys_authorize.expires_time;
|
||
}
|
||
|
||
|