Seeduino-Arch-Pro Ethernet
In order to make the Seeduino-Arch-Pro successfully init the ethernet interface... you need to have a
extern "C" void mbed_mac_address(char *mac)
routine. So something like this to hard code a MAC address:
extern "C" void mbed_mac_address(char *mac){
mac[0] = 0x00; mac[1] = 0x02; mac[2] = 0xF7; mac[3] = 0xF1; mac[4] = 0x91; mac[5] = 0x9F;
};
or something dynamic based on serial number of the NXP chip:
extern "C" void mbed_mac_address(char *mac)
{
static char buf[64] = {0};
IAP iap;
int32_t *block = iap.read_serial();
uint32_t serial_number[5] = {0};
memset(buf, 0, sizeof(buf));
serial_number[0] = *(block);
serial_number[1] = *(block+1);
// we only want bottom 16 bits of word1 (MAC bits 32-47)
// and bit 9 forced to 1, bit 8 forced to 0
// Locally administered MAC, reduced conflicts
// http://en.wikipedia.org/wiki/MAC_address
//serial_number[0] |= 0x00000200;
//serial_number[0] &= 0x0000FEFF;
memcpy(mac, (uint8_t*) &serial_number[0], 6);
mac[0] |= 0x02;
mac[0] &= 0xFE;
mac[5] |= 0x02;
mac[5] &= 0xFE;
snprintf(buf, 16, "%4X%08X", serial_number[0], serial_number[1]);
}
not sure that final snprintf command is necessary.
Please log in to post comments.
