/********************************************************************* * * External serial data EEPROM Access Defs. * ********************************************************************* * FileName: XEEPROM.h * Dependencies: None * Processor: PIC18, PIC24F, PIC24H, dsPIC30F, dsPIC33F * Complier: Microchip C18 v3.02 or higher * Microchip C30 v2.01 or higher * Company: Microchip Technology, Inc. * * Software License Agreement * * Copyright © 2002-2007 Microchip Technology Inc. All rights * reserved. * * Microchip licenses to you the right to use, modify, copy, and * distribute: * (i) the Software when embedded on a Microchip microcontroller or * digital signal controller product (“Device”) which is * integrated into Licensee’s product; or * (ii) ONLY the Software driver source files ENC28J60.c and * ENC28J60.h ported to a non-Microchip device used in * conjunction with a Microchip ethernet controller for the * sole purpose of interfacing with the ethernet controller. * * You should refer to the license agreement accompanying this * Software for additional information regarding your rights and * obligations. * * THE SOFTWARE AND DOCUMENTATION ARE PROVIDED “AS IS” WITHOUT * WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT * LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL * MICROCHIP BE LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF * PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS * BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE * THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER * SIMILAR COSTS, WHETHER ASSERTED ON THE BASIS OF CONTRACT, TORT * (INCLUDING NEGLIGENCE), BREACH OF WARRANTY, OR OTHERWISE. * * * Author Date Comment *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Nilesh Rajbharti 5/20/02 Original (Rev. 1.0) ********************************************************************/ #ifndef __XEEPROM_H #define __XEEPROM_H typedef unsigned short int XEE_ADDR; typedef BOOL XEE_RESULT; #define XEE_SUCCESS FALSE /********************************************************************* * Function: void XEEInit(void) * * PreCondition: None * * Input: baud - SSPADD value for bit rate. * * Output: None * * Side Effects: None * * Overview: Initialize I2C module to communicate to serial * EEPROM. * * Note: None ********************************************************************/ void XEEInit(void); /********************************************************************* * Function: XEE_RESULT XEEBeginWrite(XEE_ADDR address) * * PreCondition: XEEInit() is already called. * * Input: control - data EEPROM control code * address - address to where to write * * Output: XEE_SUCCESS if successful * other value if failed. * * Side Effects: None * * Overview: Sets up internal address counter of EEPROM. * * Note: This function does not release the I2C bus. * User must close XEEEndWrite() after this function * is called to relase the I2C bus. ********************************************************************/ XEE_RESULT XEEBeginWrite(XEE_ADDR address); /********************************************************************* * Function: XEE_RESULT XEEWrite(unsigned char val) * * PreCondition: XEEInit() && XEEBeginWrite() are already called. * * Input: val to be written * * Output: XEE_SUCCESS if successful * other value if failed. * * Side Effects: None * * Overview: Writes given value 'val' at current address. * Current address is set by XEEBeginWrite() * and is incremented by every XEEWrite(). * * Note: This function does not initiate the write cycle; * it simply loads given value into internal page buffer. * This function does not release the I2C bus. * User must close XEEEndWrite() after this function * is called to relase the I2C bus. ********************************************************************/ XEE_RESULT XEEWrite(unsigned char val); /********************************************************************* * Function: XEE_RESULT XEEEndWrite(void) * * PreCondition: XEEInit() && XEEBeginWrite() are already called. * * Input: None * * Output: XEE_SUCCESS if successful * other value if failed. * * Side Effects: None * * Overview: Instructs EEPROM to begin write cycle. * * Note: Call this function after either page full of bytes * written or no more bytes are left to load. * This function initiates the write cycle. * User must call for XEEWait() to ensure that write * cycle is finished before calling any other * routine. ********************************************************************/ XEE_RESULT XEEEndWrite(void); /********************************************************************* * Function: XEE_RESULT XEEBeginRead(unsigned char control, * XEE_ADDR address) * * PreCondition: XEEInit() is already called. * * Input: control - EEPROM control and address code. * address - Address at which read is to be performed. * * Output: XEE_SUCCESS if successful * other value if failed. * * Side Effects: None * * Overview: Sets internal address counter to given address. * Puts EEPROM in sequential read mode. * * Note: This function does not release I2C bus. * User must call XEEEndRead() when read is not longer * needed; I2C bus will released after XEEEndRead() * is called. ********************************************************************/ XEE_RESULT XEEBeginRead(XEE_ADDR address); /********************************************************************* * Function: XEE_RESULT XEERead(void) * * PreCondition: XEEInit() && XEEBeginRead() are already called. * * Input: None * * Output: XEE_SUCCESS if successful * other value if failed. * * Side Effects: None * * Overview: Reads next byte from EEPROM; internal address * is incremented by one. * * Note: This function does not release I2C bus. * User must call XEEEndRead() when read is not longer * needed; I2C bus will released after XEEEndRead() * is called. ********************************************************************/ unsigned char XEERead(void); /********************************************************************* * Function: XEE_RESULT XEEEndRead(void) * * PreCondition: XEEInit() && XEEBeginRead() are already called. * * Input: None * * Output: XEE_SUCCESS if successful * other value if failed. * * Side Effects: None * * Overview: Ends sequential read cycle. * * Note: This function ends seuential cycle that was in * progress. It releases I2C bus. ********************************************************************/ XEE_RESULT XEEEndRead(void); /********************************************************************* * Function: XEE_RESULT XEEReadArray(unsigned char control, * XEE_ADDR address, * unsigned char *buffer, * unsigned char length) * * PreCondition: XEEInit() is already called. * * Input: control - EEPROM control and address code. * address - Address from where array is to be read * buffer - Caller supplied buffer to hold the data * length - Number of bytes to read. * * Output: XEE_SUCCESS if successful * other value if failed. * * Side Effects: None * * Overview: Reads desired number of bytes in sequential mode. * This function performs all necessary steps * and releases the bus when finished. * * Note: None ********************************************************************/ XEE_RESULT XEEReadArray(XEE_ADDR address, unsigned char *buffer, unsigned char length); /********************************************************************* * Function: BOOL XEEIsBusy(void) * * PreCondition: XEEInit() is already called. * * Input: None * * Output: FALSE if EEPROM is not busy * TRUE if EEPROM is busy or operation failed * * Side Effects: None * * Overview: Requests ACK from EEPROM or checks status register * * Note: None ********************************************************************/ BOOL XEEIsBusy(void); #endif