LL01/code_boot_out/qm/common/common_memory.c
2025-04-26 16:03:23 +08:00

138 lines
4.6 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/** ##########################################################################
** Filename : common_types.h
** Project :
** Module :
** Processor :
** Version : 1.1
** Compiler :
** Date/Time :
** Abstract :
** Contents :
** Note : 主要用於批量處理數據,如初始化,復制,清除等等
**
** (c) Copyright dmdz Co.,Ltd
** --------------------------------------------------------------------------
** R E V I S I O N H I S T O R Y
** --------------------------------------------------------------------------
** Date Ver Author Description
** -20230602- --V1.0-- --mingyea--- --初版--
** -20231012- --V1.1-- --mingyea--- 删除 common_get_str_lengthcommon_string_comparecommon_memory_compare_u16common_memory_copys_u16
** #########################################################################*/
/*---------------------------------------------------------------------------
- I N C L U D E F I L E S
----------------------------------------------------------------------------*/
#include "common_memory.h"
#include "cpu.h"
/*---------------------------------------------------------------------------
- D E F I N E S / M A C R O S
----------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
- T Y P E D E F I N I T I O N S
----------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
- S T A T I C V A R I A B L E S
----------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
- G L O B A L V A R I A B L E S
----------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
- C O N S T A N T S
----------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
- F U N C T I O N P R O T O T Y P E
----------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
|Prototype : void common_memory_copys(void)
|Called by : None
|Preconditions : None
|Input parameters : None
|Output parameters : None
|Return value : None
|Description : u8类型的数据拷贝
----------------------------------------------------------------------------*/
void common_memory_copys(u8* dst,const u8* src,u16 length)
{
u16 i = 0u;
for(i = 0u; i < length; i++)
{
dst[i] = src[i];
}
} /* End of function common_memory_copys*/
/*---------------------------------------------------------------------------
|Prototype : void common_memory_clear(u8 *dst , u16 length)
|Called by : None
|Preconditions : None
|Input parameters : None
|Output parameters : None
|Return value : None
|Description : u8类型的数据清零
----------------------------------------------------------------------------*/
void common_memory_clear(u8 *dst , u16 length)
{
u16 i = 0u;
for(i = 0u; i < length; i++)
{
dst[i] = 0u;
}
} /* End of function common_memory_clear*/
/*---------------------------------------------------------------------------
|Prototype : void common_memory_fill(u8 *dst , u8 value, u16 length)
|Called by : None
|Preconditions : None
|Input parameters : None
|Output parameters : None
|Return value : None
|Description : 将一串数填充为相同的值
----------------------------------------------------------------------------*/
void common_memory_fill(u8 *dst , u8 value, u16 length)
{
u16 i;
for(i = 0u; i < length; i++)
{
dst[i] = value;
}
} /* End of function common_memory_fill*/
/*---------------------------------------------------------------------------
|Prototype : void common_memory_copys_u16(u16* dst,const u16* src,u16 length)
|Called by : None
|Preconditions : None
|Input parameters : None
|Output parameters : None
|Return value : MEMORY_RESULT_DIFFERENT/ MEMORY_RESULT_SAME
|Description : u8类型的两个数组比较
----------------------------------------------------------------------------*/
memory_result_t common_memory_compare(const u8 *dst , const u8 *src, u16 length)
{
u16 i;
for(i = 0u; i < length; i++)
{
if(dst[i] != src[i])
{
return MEMORY_RESULT_DIFFERENT;
}
}
return MEMORY_RESULT_SAME;
} /* End of function common_memory_compare*/
/* [] END OF FILE */