Zigbee Module Examples

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
hal_Microchip_24xxxxx_eeprom.c File Reference

Interface driver to Microchip EEPROM and equivalents (Atmel 24C etc.) via I2C. More...

`#include "hal.h"`
`#include "hal_Microchip_24xxxxx_eeprom.h"`
`#include "../Common/utilities.h"`
`#include <stdint.h>`
`#include <string.h>`

## Functions
int16_t | eepromRandomRead (uint16_t address)
int16_t | eepromByteWrite (uint16_t address, uint8_t value)
int16_t | eepromSequentialRead (uint16_t address, uint8_t *data, uint8_t numBytes)
uint8_t | eepromReadCurrentAddress ()
int16_t | eepromPageWrite (uint16_t address, uint8_t *data, uint8_t numBytes)
void | eepromInit ()
uint8_t | eepromBusy ()

## Detailed Description

Interface driver to Microchip EEPROM and equivalents (Atmel 24C etc.) via I2C.

See also:
  http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en010817
  http://www.atmel.com/devices/at24c128c.aspx

Rev:
  1642

Author:
  dsmith

Date:
  2012-10-31 11:17:04 -0700 (Wed, 31 Oct 2012)

# Support

Please refer to the wiki at www.anaren.com/air-wiki-zigbee for more information. Additional support is available via email at the following addresses:

- Questions on how to use the product: AIR@a.nosp@m.nare.nosp@m.n.com
- Feature requests, comments, and improvements: featu.nosp@m.rere.nosp@m.quest.nosp@m.s@te.nosp@m.slaco.nosp@m.ntro.nosp@m.ls.co.nosp@m.m
- Consulting engagements: sales.nosp@m.@tes.nosp@m.lacon.nosp@m.trol.nosp@m.s.com

# License

Copyright (c) 2012 Anaren Microwave. All rights reserved. This Software may only be used with an Anaren A2530E24AZ1, A2530E24CZ1, A2530R24AZ1, or A2530R24CZ1 module. Redistribution and use in source and binary forms, with or without modification, are subject to the Software License Agreement in the file "anaren_eula.txt"

YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL ANAREN MICROWAVE OR TESLA CONTROLS BE LIABLE OR OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSE INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.

## Function Documentation

uint8_t eepromBusy | ( |  | ) |

    Tests whether EEPROM is busy using Acknowledgment Polling

Returns:
  1 if busy, 0 if not

int16_t eepromByteWrite | ( | uint16_t | address,
|  | uint8_t | value
| ) |  |

    Writes the value of a single 8 bit value to the EEPROM

Precondition:
  I2C bus was initialized with i2cInit(EEPROM_I2C_ADDRESS)

Parameters:

  address | which register to write to
  value | the value to be written to the EEPROM

Returns:
  0 if success, else an error code.

void eepromInit | ( |  | ) |

    Initialize the EEPROM.

Precondition:
  I2C interface on microcontroller was configured correctly

Note:
  Part maximum baud rate 400kHz for I2C.

int16_t eepromPageWrite | ( | uint16_t | address,
|  | uint8_t * | data,
|  | uint8_t | numBytes
| ) |  |

    Writes a number of bytes to the EEPROM

Precondition:
  I2C bus was initialized with i2cInit(EEPROM_I2C_ADDRESS)

Parameters:

  address | which address to start writing to
  data | the data to write
  numBytes | how many bytes to write.

Precondition:
  data holds the bytes to write

Returns:
  0 if success, else an error code.

Note:
  the EEPROM is not immediately available following this call since it takes ~5mSec to write. See data sheet for write timing.

int16_t eepromRandomRead | ( | uint16_t | address | ) |

    Implements an i2c "random read" - reading the specified address from the EEPROM

Precondition:
  I2C bus was initialized with i2cInit(EEPROM_I2C_ADDRESS)

Parameters:

  address | which address to read

Returns:
  the value of the register, or -1 if error

uint8_t eepromReadCurrentAddress | ( |  | ) |

    Reads the address at the EEPROM's current address pointer.

Returns:
  the value of the register

int16_t eepromSequentialRead | ( | uint16_t | address,
|  | uint8_t * | data,
|  | uint8_t | numBytes
| ) |  |

    Reads a number of bytes from the EEPROM

Precondition:
  I2C bus was initialized with i2cInit(EEPROM_I2C_ADDRESS)

Parameters:

  address | which address to start reading from
  data | where to write the data to
  numBytes | how many bytes to read.

Precondition:
  data is large enough to hold numBytes

Returns:
  0 if success, else an error code.