We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]
Rating:
Author: MIKROE
Last Updated: 2019-05-27
Package Version: 1.0.0.1
mikroSDK Library: 1.0.0.0
Category: EEPROM
Downloaded: 4061 times
Not followed.
License: MIT license
MAC Address click provides a unique node address for your application. It also has 1Kbit of writable EEPROM memory. MAC Address click carries the 24AA025E64 2K I2C Serial EEPROM with EUI-64 node identity. The click is designed to run on either 3.3V or 5V power supply.
Do you want to subscribe in order to receive notifications regarding "MAC Address click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "MAC Address click" changes.
Do you want to report abuse regarding "MAC Address click".
Library Description
The library covers all the necessary functions to control MAC Address click board.
The library performs the communication with the device via I2C protocol by writing to registers and by reading from registers.
Key functions:
void macaddress_getMAC( uint8_t *readMac )
- Read MAC address function.void macaddress_writeByte( uint8_t regAddress, uint8_t writeData )
- Generic write the byte of data function.void macaddress_readMulti( uint8_t startAddr, uint8_t *readData, uint8_t nBytes )
- Generic read data - sequential function.Examples description
The application is composed of the three sections :
void applicationTask() { macaddress_getMAC( &readMac ); Delay_100ms(); mikrobus_logWrite( " MAC Address : ", _LOG_TEXT ); for( cnt = 0; cnt < 6; cnt++ ) { ByteToHex( readMac[ cnt ], logText ); ltrim( logText ); mikrobus_logWrite( logText, _LOG_TEXT ); if( cnt != 5 ) { mikrobus_logWrite( ":", _LOG_TEXT ); } } mikrobus_logWrite( "", _LOG_LINE ); mikrobus_logWrite( "---------------------------------", _LOG_LINE ); mikrobus_logWrite( " Write Single Byte Test : ", _LOG_LINE ); macaddress_writeByte( bufferLoop, bufferLoop + 1 ); ByteToHex( bufferLoop + 1, logText ); ltrim( logText ); mikrobus_logWrite( " Byte value [ ", _LOG_TEXT ); mikrobus_logWrite( logText, _LOG_TEXT ); mikrobus_logWrite( " ] successfully written to [ ", _LOG_TEXT ); ByteToHex( bufferLoop, logText ); ltrim( logText ); mikrobus_logWrite( logText, _LOG_TEXT ); mikrobus_logWrite( " ] address", _LOG_LINE ); mikrobus_logWrite( "-----------------------------", _LOG_TEXT ); mikrobus_logWrite( "-----------------------------", _LOG_LINE ); mikrobus_logWrite( " Read Single Byte Test ", _LOG_TEXT ); macaddress_readByte( bufferLoop ); ByteToHex( bufferLoop + 1, logText ); ltrim( logText ); mikrobus_logWrite( "", _LOG_LINE ); mikrobus_logWrite( " Byte value [ ", _LOG_TEXT ); mikrobus_logWrite( logText, _LOG_TEXT ); mikrobus_logWrite( " ] successfully read from [ ", _LOG_TEXT ); ByteToHex( bufferLoop, logText ); ltrim( logText ); mikrobus_logWrite( logText, _LOG_TEXT ); mikrobus_logWrite( " ] address", _LOG_LINE ); mikrobus_logWrite( "-----------------------------", _LOG_TEXT ); mikrobus_logWrite( "-----------------------------", _LOG_LINE ); macaddress_writeMulti( bufferLoop, &buffer, 12 ); Delay_100ms(); mikrobus_logWrite( " Array values : ", _LOG_LINE ); for( cnt = 0; cnt < 12; cnt++ ) { ByteToHex( buffer[cnt], logText ); ltrim( logText ); mikrobus_logWrite( "[ ", _LOG_TEXT ); mikrobus_logWrite( logText, _LOG_TEXT ); mikrobus_logWrite( " ]", _LOG_TEXT ); } ByteToHex( bufferLoop, logText ); ltrim( logText ); mikrobus_logWrite( " successfully written to [ ", _LOG_TEXT ); mikrobus_logWrite( logText, _LOG_TEXT ); mikrobus_logWrite( " ] address and forward", _LOG_LINE ); mikrobus_logWrite( "-----------------------------", _LOG_TEXT ); mikrobus_logWrite( "-----------------------------", _LOG_LINE ); macaddress_readMulti( bufferLoop, &buffer, 12 ); Delay_100ms(); mikrobus_logWrite( " Array values : ", _LOG_LINE ); for( cnt = 0; cnt < 12; cnt++ ) { ByteToHex( buffer[cnt], logText ); ltrim( logText ); mikrobus_logWrite( "[ ", _LOG_TEXT ); mikrobus_logWrite( logText, _LOG_TEXT ); mikrobus_logWrite( " ]", _LOG_TEXT ); } ByteToHex( bufferLoop, logText ); ltrim( logText ); mikrobus_logWrite( " successfully read from [ ", _LOG_TEXT ); mikrobus_logWrite( logText, _LOG_TEXT ); mikrobus_logWrite( " ] address and forward", _LOG_LINE ); mikrobus_logWrite( "-----------------------------", _LOG_TEXT ); mikrobus_logWrite( "-----------------------------", _LOG_LINE ); if ( bufferLoop >= _MACADDRESS_END_ADDR ) { bufferLoop = 0; } bufferLoop++; Delay_1sec(); }
Other mikroE Libraries used in the example:
I2C
UART
Conversions
Additional notes and informations
Depending on the development board you are using, you may need USB UART click, USB UART 2 click or RS232 click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all MikroElektronika compilers, or any other terminal application of your choice, can be used to read the message.