feat:新建项目文件
BLV主机C1P模块
This commit is contained in:
92
MCU_Driver/blv_authorize.c
Normal file
92
MCU_Driver/blv_authorize.c
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* 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 : <20><><EFBFBD><EFBFBD>BLVϵͳ<CFB5><CDB3>Ȩ״̬
|
||||
* Input :
|
||||
expires_time :<3A><>Ȩʱ<C8A8><CAB1>
|
||||
* 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ϵͳ<CFB5><CDB3>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD>
|
||||
* Input :
|
||||
utc_time :<3A><><EFBFBD><EFBFBD>utcʱ<63><CAB1>
|
||||
* 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;
|
||||
/*<2A><><EFBFBD>ʱ<E2B5BD>䵽<EFBFBD>ں<DABA><F3A3ACBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC>λ<EFBFBD><CEBB>ͬʱ<CDAC><CAB1><EFBFBD>浽Flash<73><68>*/
|
||||
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 : <20><>ȡ<EFBFBD><C8A1>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD>״̬
|
||||
* Input :
|
||||
0x00<30><30><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0>Ȩδ<C8A8><CEB4><EFBFBD><EFBFBD>
|
||||
0x01<30><31><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD>
|
||||
*******************************************************************************/
|
||||
__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 : <20><>ȡ<EFBFBD><C8A1>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD>״̬
|
||||
* Input : None
|
||||
* Return :
|
||||
0x00<30><30><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0>Ȩδ<C8A8><CEB4><EFBFBD><EFBFBD>
|
||||
0x01<30><31><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD>
|
||||
*******************************************************************************/
|
||||
__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 : <20><>ȡ<EFBFBD><C8A1>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
||||
* Input : None
|
||||
* Return : <20><>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
||||
*******************************************************************************/
|
||||
__attribute__((section(".non_0_wait"))) uint32_t Get_Authorize_UnixTime(void)
|
||||
{
|
||||
return sys_authorize.expires_time;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user