Nut/OS  4.10.3
API Reference
eeprom.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2009 by Rittal GmbH & Co. KG,
00003  * Ulrich Prinz <prinz.u@rittal.de> All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * 1. Redistributions of source code must retain the above copyright
00010  *    notice, this list of conditions and the following disclaimer.
00011  * 2. Redistributions in binary form must reproduce the above copyright
00012  *    notice, this list of conditions and the following disclaimer in the
00013  *    documentation and/or other materials provided with the distribution.
00014  * 3. Neither the name of the copyright holders nor the names of
00015  *    contributors may be used to endorse or promote products derived
00016  *    from this software without specific prior written permission.
00017  *
00018  * THIS SOFTWARE IS PROVIDED BY EMBEDDED IT AND CONTRIBUTORS
00019  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00020  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00021  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EMBEDDED IT
00022  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00023  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00024  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00025  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00026  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00027  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00028  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029  *
00030  * For additional information see http://www.ethernut.de/
00031  *
00032  */
00033 
00034 /*
00035  * $Log$
00036  *
00037  * Revision 1.0  2009/04/13 ulrichprinz
00038  * First checkin, abstraction interface for EEPROM chips (currently SAM7X256 is 
00039  * tested only)
00040  *
00041  */
00042 #ifndef _DEV_EEPROM_H_
00043 #define _DEV_EEPROM_H_
00044 
00045 #include <stdint.h>
00046 #include <dev/twif.h>
00047 #include <dev/at24c.h>
00048 #include <dev/eeprom.h>
00049 
00050 static struct at24c at24c32s;
00051 
00052 /****************************************************************************/
00053 int EEInit( void )
00054 /****************************************************************************/
00055 {
00056     uint8_t dummy;
00057     at24c32s.PageSize = 32;
00058     at24c32s.NumOfPage = 128;
00059     at24c32s.EepromSize = 32*128;
00060     at24c32s.SlaveAddress = NUT_CONFIG_AT24_ADR;
00061         at24c32s.IAddrW = 2;
00062         at24c32s.Timeout = 20;
00063     
00064     //strcpy (at24c32s.EepromName, "AT24C32" );
00065     
00066     /* Do a dummy read for communication test */
00067     return At24cRead( &at24c32s, &dummy, 1, 0);
00068 }
00069 
00070 /****************************************************************************/
00071 int EEWriteData( uint16_t addr, CONST void *data, uint16_t len )
00072 /****************************************************************************/
00073 {
00074         return At24cWrite( &at24c32s, (uint8_t *)data, len, addr );
00075 }
00076 
00077 /****************************************************************************/
00078 int EEReadData( uint16_t addr, void *data, uint16_t len )
00079 /****************************************************************************/
00080 {
00081         return At24cRead( &at24c32s, (uint8_t *)data, len, addr );
00082 }
00083 #endif //_DEV_EEPROM_H_