📄 setmac.c
字号:
/*
* Copyright 2005 by Spectrum Digital Incorporated.
* All rights reserved. Property of Spectrum Digital Incorporated.
*
* Not for distribution.
*/
/*
* Set the MAC address on DaVinci EVM
*
*/
#include "stdio.h"
#include "davincievm.h"
#include "davincievm_eeprom.h"
/* ------------------------------------------------------------------------ *
* *
* main( ) *
* *
* ------------------------------------------------------------------------ */
Int16 main( )
{
Uint16 i;
Uint16 retcode;
Uint8 MacAddressToWrite[6];
Uint8 CurrentMacAddress[6] = { 0, 0, 0, 0, 0, 0 };
MacAddressToWrite[0] = 0x00; // This is part of the Spectrum Digital OUI reserved
MacAddressToWrite[1] = 0x0E; // portion of the Ethernet MAC namespace which is
MacAddressToWrite[2] = 0x99; // registered with the namespace authority ( the IEEE ).
MacAddressToWrite[3] = 0xFF; // You are only authorized to use the MAC address prog-
MacAddressToWrite[4] = 0xFF; // rammed into your board at Spectrum Digital. Any
MacAddressToWrite[5] = 0xFF; // use of the Spectrum Digital namespace is a violation
// of the rules imposed by the IEEE.
/* Call BSL init */
DAVINCIEVM_init( );
/* Call EEPROM init */
DAVINCIEVM_EEPROM_init( );
/* Write Ethernet physical address to 0x7F00 of I2C EEPROM */
DAVINCIEVM_EEPROM_write( ( Uint32 )MacAddressToWrite, 0x00007F00, 6 );
/* A short delay to allow the write to be completed */
DAVINCIEVM_wait( 250000 );
/* Read address back and verify */
DAVINCIEVM_EEPROM_read( 0x00007F00, ( Uint32 )CurrentMacAddress, 6 );
retcode = 0;
for ( i = 0; i < 6; i++ )
if ( MacAddressToWrite[i] != CurrentMacAddress[i] )
retcode = 1;
if ( retcode == 0 )
{
printf( "Writing MAC address... PASSED\n\n");
printf( " New address is [%02x-%02x-%02x-%02x-%02x-%02x]\n",
MacAddressToWrite[0], MacAddressToWrite[1], MacAddressToWrite[2],
MacAddressToWrite[3], MacAddressToWrite[4], MacAddressToWrite[5] );
}
else
{
printf( "Writing MAC address... FAILED\n" );
}
return retcode;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -