176 lines
5.4 KiB
C
176 lines
5.4 KiB
C
/*
|
||
* log_api.c
|
||
*
|
||
* Created on: Jul 29, 2025
|
||
* Author: cc
|
||
*/
|
||
|
||
#include "rw_logging.h"
|
||
#include "SPI_SRAM.h"
|
||
#include "Log_api.h"
|
||
#include "string.h"
|
||
|
||
uint32_t SYS_Log_Switch = (LogType_Launcher_SWITCH << LogType_Launcher_bit) + \
|
||
(LogType_SYS_Record_SWITCH << LogType_SYS_Record_bit) + \
|
||
(LogType_Device_COMM_SWITCH << LogType_Device_COMM_bit) + \
|
||
(LogType_Device_Online_SWITCH << LogType_Device_Online_bit) + \
|
||
(LogType_Global_Parameters_SWITCH << LogType_Global_Parameters_bit) + \
|
||
(LogType_Net_COMM_SWITCH << LogType_Net_COMM_bit) + \
|
||
(LogType_Logic_Record_SWITCH << LogType_Logic_Record_bit);
|
||
|
||
|
||
/*******************************************************************************
|
||
* Function Name : LOG_Launcher_APP_Check_Record
|
||
* Description : Launcher类型 - 校验APP
|
||
* Input :
|
||
state :状态
|
||
0x00:相同、
|
||
0x01:版本号不同、
|
||
0x02:CRC校验不同、
|
||
0x03:Flash的APP地址错误、
|
||
0x04:Flash APP数据校验错误、
|
||
0x05:Flash中APP标志未置位、
|
||
0x06:Flash 特征区的CRC校验错误、
|
||
0x07:MCU Flash数据校验错误、
|
||
0x08:MCU Flash的APP标志未置位、
|
||
0x09:MCU Flash特征区的CRC校验错误
|
||
* Return : None
|
||
*******************************************************************************/
|
||
void LOG_Launcher_APP_Check_Record(uint8_t state)
|
||
{
|
||
if(LogType_Enable && (SYS_Log_Switch & (1 << LogType_Launcher_bit )) )
|
||
{
|
||
uint8_t temp_buff[3] = {0};
|
||
|
||
temp_buff[0] = LLauncher_App_Check;
|
||
temp_buff[1] = state;
|
||
|
||
Log_write_sram(LogType_Launcher,temp_buff,2);
|
||
}
|
||
}
|
||
|
||
/*******************************************************************************
|
||
* Function Name : LOG_Launcher_APP_Check_Record
|
||
* Description : Launcher类型 - 校验APP
|
||
* Input :
|
||
state :状态
|
||
0x00:成功
|
||
0x01:失败
|
||
* Return : None
|
||
*******************************************************************************/
|
||
void LOG_Launcher_Read_App_Record(uint8_t state)
|
||
{
|
||
if(LogType_Enable && (SYS_Log_Switch & (1 << LogType_Launcher_bit )) )
|
||
{
|
||
uint8_t temp_buff[3] = {0};
|
||
|
||
temp_buff[0] = LLauncher_Read_App;
|
||
temp_buff[1] = state;
|
||
|
||
Log_write_sram(LogType_Launcher,temp_buff,2);
|
||
}
|
||
}
|
||
|
||
/*******************************************************************************
|
||
* Function Name : LOG_Launcher_Write_Flash_Record
|
||
* Description : Launcher类型 - Flash写入
|
||
* Input :
|
||
addr :写入地址
|
||
len :写入长度
|
||
* Return : None
|
||
*******************************************************************************/
|
||
void LOG_Launcher_Write_Flash_Record(uint32_t addr,uint16_t len)
|
||
{
|
||
if(LogType_Enable && (SYS_Log_Switch & (1 << LogType_Launcher_bit )) )
|
||
{
|
||
uint8_t temp_buff[7] = {0};
|
||
|
||
temp_buff[0] = LLauncher_Write_Flash;
|
||
temp_buff[1] = addr & 0xFF;
|
||
temp_buff[2] = (addr >> 8) & 0xFF;
|
||
temp_buff[3] = (addr >> 16) & 0xFF;
|
||
temp_buff[4] = (addr >> 24) & 0xFF;
|
||
temp_buff[5] = len & 0xFF;
|
||
temp_buff[6] = (len >> 8) & 0xFF;
|
||
|
||
Log_write_sram(LogType_Launcher,temp_buff,7);
|
||
}
|
||
}
|
||
|
||
/*******************************************************************************
|
||
* Function Name : LOG_Launcher_Factory_Reset_Record
|
||
* Description : Launcher类型 - 恢复出厂设置
|
||
* Input :
|
||
state:
|
||
0x01:写入成功
|
||
0x02:写入失败 - 没有出厂程序
|
||
0x03:写入失败 - 出厂程序写入失败
|
||
* Return : None
|
||
*******************************************************************************/
|
||
void LOG_Launcher_Factory_Reset_Record(uint8_t state)
|
||
{
|
||
if(LogType_Enable && (SYS_Log_Switch & (1 << LogType_Launcher_bit )) )
|
||
{
|
||
uint8_t temp_buff[3] = {0};
|
||
|
||
temp_buff[0] = LLauncher_Factory_Reset;
|
||
temp_buff[1] = state;
|
||
|
||
Log_write_sram(LogType_Launcher,temp_buff,2);
|
||
}
|
||
}
|
||
|
||
/*******************************************************************************
|
||
* Function Name : LOG_Launcher_Factory_Reset_Record
|
||
* Description : Launcher类型 - 复位源
|
||
* Input :
|
||
sour:复位信号值
|
||
0x00:软件复位
|
||
0x01:上电复位
|
||
0x02:看门狗复位
|
||
0x03:外部手动复位
|
||
0x05:从下电模式唤醒时的复位 - 通过WCHISPTool烧录后的复位
|
||
* Return : None
|
||
*******************************************************************************/
|
||
void LOG_Launcher_Reset_Source_Record(uint8_t sour)
|
||
{
|
||
if(LogType_Enable && (SYS_Log_Switch & (1 << LogType_Launcher_bit )) )
|
||
{
|
||
uint8_t temp_buff[3] = {0};
|
||
|
||
temp_buff[0] = LLauncher_Reset_Source;
|
||
temp_buff[1] = sour;
|
||
|
||
Log_write_sram(LogType_Launcher,temp_buff,2);
|
||
}
|
||
}
|
||
|
||
/*******************************************************************************
|
||
* Function Name : LOG_Launcher_Factory_Reset_Record
|
||
* Description : Launcher类型 - RCU本地按键
|
||
* Input :
|
||
state:状态
|
||
0x01:点按
|
||
0x02:长按
|
||
0x03:长按松开
|
||
0x04:达到恢复出厂设置状态
|
||
* Return : None
|
||
*******************************************************************************/
|
||
void LOG_Launcher_RCU_Key_State_Record(uint8_t state)
|
||
{
|
||
if(LogType_Enable && (SYS_Log_Switch & (1 << LogType_Launcher_bit )) )
|
||
{
|
||
uint8_t temp_buff[3] = {0};
|
||
|
||
temp_buff[0] = LLauncher_RCUKey_State;
|
||
temp_buff[1] = state;
|
||
|
||
Log_write_sram(LogType_Launcher,temp_buff,2);
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|