stm32_ota/SYSTEM/MAC/mac.c

73 lines
3.1 KiB
C
Raw Normal View History

2023-12-15 06:28:06 +00:00
#include "mac.h"
#include <string.h>
#include "syslib.h"
/********************************************************************************
* @file mac.c
* @author <EFBFBD>̳ϿƼ<EFBFBD> Mr.Wang
* @version V1.0.0
* @date 11-Dec-2018
* @brief <EFBFBD>stm32Ψһʶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľӿڡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD><EFBFBD><EFBFBD>DATA<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŵĽӿ<EFBFBD>
******************************************************************************
* @<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD>
* 1<EFBFBD><EFBFBD>GetDeviceMacAddress()<EFBFBD>stm32Ψһʶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>dz<EFBFBD>֮Ϊ<EFBFBD>MAC<EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>Ľӿ<EFBFBD>
* 2<EFBFBD><EFBFBD>Query_AppVersionIOEXTI()<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD><EFBFBD><EFBFBD>DATA<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŵĽӿ<EFBFBD>
*******************************************************************************/
/**************************************************************************************************
* <EFBFBD><EFBFBD> <EFBFBD>ƣ<EFBFBD> void Query_AppVersion( char *version)
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> @param1 char *version: <EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD><EFBFBD>ַ<EFBFBD>ָ<EFBFBD><EFBFBD> <EFBFBD><EFBFBD>Nov 24 2014<EFBFBD><EFBFBD>
* ԭ<EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>KEIL<EFBFBD><EFBFBD><EFBFBD>̱<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ϵͳ<EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>__DATE__Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>__TIME__Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
*************************************************************************************************/
void Query_AppVersion( char *version)
{
memset(version, 0, VERSION_LEN);
strncpy( (char*)version, __DATE__, VERSION_LEN ) ; //<2F><><EFBFBD><EFBFBD>11bytes
#ifdef Beta
*(version+3) = 'T' ; //<2F><><EFBFBD><EFBFBD><EFBFBD>汾Ϊδ<CEAA><CEB4><EFBFBD><EFBFBD><EFBFBD>İ汾 <20><><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD>ŵ<EFBFBD><34>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>T<EFBFBD><54>
#endif
#ifdef CUSTOM
*(version+6) = 'C' ; //<2F><><EFBFBD><EFBFBD><EFBFBD>汾Ϊ<E6B1BE><CEAA><EFBFBD>ư汾 <20><><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD>ŵ<EFBFBD><37>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>C<EFBFBD><43>
#endif
}
/**************************************************************************************************
* <EFBFBD><EFBFBD> <EFBFBD>ƣ<EFBFBD> void GetDeviceMacAddress(uint8_t *macAddressNBytes, MACIDFORMAT_e eMacIdFormat)
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>ȡSTM32Ψһʶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>MACID
* <EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param1 MACIDFORMAT_e eMacIdFormat: MACI<EFBFBD><EFBFBD>ʲô<EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @arg1 STRMACID<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>MACID<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>16<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ24<EFBFBD>ֽ<EFBFBD>
* @arg1 HEXMACID<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>MACIDΪ16<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ12<EFBFBD>ֽ<EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* ԭ<EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD>STM32<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>FLASH<EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ψһʶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>MACID
* 0x1FFFF7E8: *(u16 *)(0x1FFFF7E8));
* 0x1FFFF7EA: *(u16 *)(0x1FFFF7E8+2));
* 0x1FFFF7EE: *(u32 *)(0x1FFFF7E8+4));
* 0x1FFFF7F6: *(u32 *)(0x1FFFF7E8+8));
*************************************************************************************************/
void GetDeviceMacAddress(uint8_t *macAddressNBytes, MACIDFORMAT_e eMacIdFormat)
{
MACID_u macAddressBytes ;
memset( macAddressBytes.macBytes, 0, MAC_BYTES_LEN/2) ;
macAddressBytes.macValue[0] = *(u32 *)(0x1FFFF7E8) ;
macAddressBytes.macValue[1] = *(u32 *)(0x1FFFF7E8+4) ;
macAddressBytes.macValue[2] = *(u32 *)(0x1FFFF7E8+8) ;
switch( eMacIdFormat )
{
case STRMACID:
ByteToHexStr(macAddressNBytes, macAddressBytes.macBytes, MAC_BYTES_LEN/2) ;
break ;
case HEXMACID:
strncpy((char*)macAddressNBytes, (const char*)macAddressBytes.macBytes, MAC_BYTES_LEN/2) ;\
break ;
default :
ByteToHexStr(macAddressNBytes, macAddressBytes.macBytes, MAC_BYTES_LEN/2) ;
break ;
}
//*(macAddressNBytes+MAC_BYTES_LEN-1) = 0x00 ; //<2F><><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>β0x00
}