6.5.4. EEPROM

EEPROM typically contains the MAC address of the node. It is expected that every node in a PAN is uniquely identified by its MAC address. It is the operator’s responsibility to ensure that they are all unique. IEEE calls such a unique address Extended Unique Identifier (EUI).

Platform currently supports interfacing to Atmel’s AT24C01C and Atmel’s AT24MAC602 EEPROM devices.

6.5.4.1. Functions

UINT8_t AT24C01C_init(UINT8_t devId)

Initializes local context for communicating to the EEPROM over I2C interface.

Parameters:
  • devId – Identity of the device.
Returns:

If successful, 1 is returned. If any error occurs, 0 is returned.

UINT8_t AT24C01C_read(UINT8_t devId, UINT8_t rdOff, UINT8_t rdCnt, UINT8_t *buff_p)

Read data from EEPROM that’s interfaced to MSP430 on I2C bus.

Parameters:
  • devId – Identity of the device.
  • rdOff – Offset in EEPROM memory where read is to be performed.
  • rdCnt – Number of bytes to read. The sum rdOff + rdCnt must not exceed AT24C01C_EEPROM_LEN, the size of EEPROM.
  • buff_p – Points to buffer where read data will be stored for caller to process. Obviously, enough valid memory should be allocated by the caller to hold rdCnt bytes of data.
Returns:

If successful, 1 is returned. If any error occurs, 0 is returned.

UINT8_t AT24C01C_write(UINT8_t devId, UINT8_t wrOff, UINT8_t wrCnt, UINT8_t *buff_p)

Write data into EEPROM that’s interfaced to MSP430 on I2C bus. Internally, the function writes byte by byte and waits for the write cycle to complete between successive writes. It uses a timer to implement the waiting for write cycle completion. In addition, function reads from EEPROM to verify that the write has been executed correctly.

Parameters:
  • devId – Identity of the device.
  • wrOff – Offset in EEPROM memory where write is to be performed.
  • wrCnt – Number of bytes to write. The sum wrOff + wrCnt must not exceed AT24C01C_EEPROM_LEN, the size of EEPROM.
  • buff_p – Points to buffer containing the data that will go into EEPROM.
Returns:

If successful, 1 is returned. If any error occurs, 0 is returned.

PLTFRM_sts_t AT24MAC602_init(const UINT8_t devId)

Initializes local context for communicating to the EEPROM over I2C interface.

Parameters:
  • devId – Identity of the device.
Returns:

PLTFRM_STS_SUCCESS is returned on success. A non-zero value indicates a failure. One possible error is PLTFRM_STS_INV_DEV_ID.

PLTFRM_sts_t AT24MAC602_readSerialNr(UINT8_t devId, UINT8_t *buff_p)

Every AT24MAC602 EEPROM has a factory-programmed 128-bit serial number. This functions reads that serial number.

Parameters:
  • devId – Identity of the device.
  • buff_p – Points to buffer where the serial number will be stored for caller to process. Obviously, enough valid memory should be allocated by the caller to hold 16 bytes of the serial number.
Returns:

PLTFRM_STS_SUCCESS is returned on success. A non-zero value indicates a failure. One possible error is PLTFRM_STS_INV_DEV_ID.

PLTFRM_sts_t AT24MAC602_readEUI64(UINT8_t devId, UINT8_t *buff_p)

Reads the 64-bit unique identifier of the node as stored in EEPROM.

Parameters:
  • devId – Identity of the device.
  • buff_p – Points to buffer where read data will be stored for caller to process. Obviously, enough valid memory should be allocated by the caller to hold 8 bytes of data.
Returns:

PLTFRM_STS_SUCCESS is returned on success. A non-zero value indicates a failure. One possible error is PLTFRM_STS_INV_DEV_ID.

PLTFRM_sts_t AT24MAC602_write(UINT8_t devId, UINT8_t wrOff, UINT8_t wrCnt, UINT8_t *buff_p)

Write data into EEPROM that’s interfaced to MSP430 on I2C bus. Internally, the function writes byte by byte and waits for the write cycle to complete between successive writes. It uses a timer to implement the waiting for write cycle completion. In addition, function reads from EEPROM to verify that the write has been executed correctly.

Parameters:
  • devId – Identity of the device.
  • wrOff – Offset in EEPROM memory where write is to be performed.
  • wrCnt – Number of bytes to write. The sum wrOff + wrCnt must not exceed AT24MAC602_EEPROM_LEN, the size of EEPROM.
  • buff_p – Points to buffer containing the data that will go into EEPROM.
Returns:

PLTFRM_STS_SUCCESS is returned on success. A non-zero value indicates a failure. One possible error is PLTFRM_STS_INV_DEV_ID.

6.5.4.2. Macros

#define AT24C01C_EEPROM_LEN  128

#define AT24C10C_I2C_ADDR_PREFIX   0x50        // 0 1010 xxx  (7 bit address)

#define AT24C01C_WRITE_CYCLE_TMO_MSECS   6    // Spec says 5 milliseconds


#define AT24MAC602_EEPROM_LEN  256


#define AT24MAC602_WRITE_CYCLE_TMO_MSECS   6    // Spec says 5 milliseconds

/*
 * The device address word consists of a mandatory one-zero sequence for the
 * first four most-significant bits 1010 (Ah) for normal read and write operations
 */
#define AT24MAC602_I2C_ADDR_PREFIX_1   0x50    // 0 1010 xxx  (7 bit address)

/*
 * and 0110 (6h) for writing to the Software Write Protect Register.
 */
#define AT24MAC602_I2C_ADDR_PREFIX_2   0x30    // 0 0110 xxx  (7 bit address)

/*
 * The AT24MAC402/602 incorporates an extended memory block containing a factory-
 * programmed 128-bit serial number. Access to this memory location is obtained by
 * beginning the device address word with a 1011 (Bh) sequence.
 *
 * The AT24MAC602 utilizes an extended memory block containing a factory-programmed
 * read-only EUI-64 address respectively. Access to this memory block is obtained by
 * beginning the device address word with a 1011 (Bh) sequence.
 */
#define AT24MAC602_I2C_ADDR_PREFIX_3   0x58    // 0 1011 xxx  (7 bit address)

/*
 * Contents of the extended memory block.
 */
#define AT24MAC602_SERIAL_NR_OFF  0x80
#define AT24MAC602_SERIAL_NR_LEN  0x10   // 128 bits

#define AT24MAC602_EUI64_OFF  0x98
#define AT24MAC602_EUI64_LEN  0x8   // 64 bits

#define AT24MAC602_EUI48_OFF  0x9a
#define AT24MAC602_EUI48_LEN  0x6   // 48 bits