00001 #ifndef _LPC177X_8X_EEPROM_H_ 00002 #define _LPC177X_8X_EEPROM_H_ 00003 00004 /* 00005 * Copyright (C) 2012 by Ole Reinhardt (ole.reinhardt@embedded-it.de) 00006 * 00007 * All rights reserved. 00008 * 00009 * Redistribution and use in source and binary forms, with or without 00010 * modification, are permitted provided that the following conditions 00011 * are met: 00012 * 00013 * 1. Redistributions of source code must retain the above copyright 00014 * notice, this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright 00016 * notice, this list of conditions and the following disclaimer in the 00017 * documentation and/or other materials provided with the distribution. 00018 * 3. Neither the name of the copyright holders nor the names of 00019 * contributors may be used to endorse or promote products derived 00020 * from this software without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00023 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00024 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00025 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00026 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00027 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00028 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 00029 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 00030 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00031 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 00032 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00033 * SUCH DAMAGE. 00034 * 00035 * For additional information see http://www.ethernut.de/ 00036 * 00037 * 00038 * Parts taken from lpc177x_8x_eeprom.h 2011-06-02 00039 * file lpc177x_8x_eeprom.h 00040 * brief Contains all macro definitions and function prototypes 00041 * support for EEPROM firmware library on LPC177x_8x 00042 * version 1.0 00043 * date 02. June. 2011 00044 * author NXP MCU SW Application Team 00045 * 00046 * Copyright(C) 2011, NXP Semiconductor 00047 * All rights reserved. 00048 * 00049 *********************************************************************** 00050 * Software that is described herein is for illustrative purposes only 00051 * which provides customers with programming information regarding the 00052 * products. This software is supplied "AS IS" without any warranties. 00053 * NXP Semiconductors assumes no responsibility or liability for the 00054 * use of the software, conveys no license or title under any patent, 00055 * copyright, or mask work right to the product. NXP Semiconductors 00056 * reserves the right to make changes in the software without 00057 * notification. NXP Semiconductors also make no representation or 00058 * warranty that such application will be suitable for the specified 00059 * use without further testing or modification. 00060 **********************************************************************/ 00061 00062 #include <inttypes.h> 00063 00064 /* We can not use the last page, as writing to it will result in a bus fault!!! */ 00065 #define EEPROM_SIZE (4096 - 64) 00066 00067 /*----------------------------------------------------------------------------* 00068 Macro defines for EEPROM command register 00069 *----------------------------------------------------------------------------*/ 00070 00071 #define EEPROM_CMD_8_BIT_READ 0 00072 #define EEPROM_CMD_16_BIT_READ 1 00073 #define EEPROM_CMD_32_BIT_READ 2 00074 #define EEPROM_CMD_8_BIT_WRITE 3 00075 #define EEPROM_CMD_16_BIT_WRITE 4 00076 #define EEPROM_CMD_32_BIT_WRITE 5 00077 #define EEPROM_CMD_ERASE_PRG_PAGE 6 00078 00079 #define EEPROM_CMD_RDPREFETCH _BV(3) 00080 00081 #define EEPROM_PAGE_SIZE 64 00082 #define EEPROM_PAGE_NUM 64 00083 00084 00085 /*----------------------------------------------------------------------------* 00086 Macro defines for EEPROM address register 00087 *----------------------------------------------------------------------------*/ 00088 00089 #define EEPROM_PAGE_OFFSET_MASK 0x3F 00090 #define EEPROM_PAGE_NUM_MASK (0x3F << 6) 00091 #define EEPROM_PAGE_OFFSET(n) ((n) & 0x3F) 00092 #define EEPROM_PAGE_ADRESS(n) (((n) & 0x3F) << 6) 00093 00094 00095 /*----------------------------------------------------------------------------* 00096 Macro defines for EEPROM write data register 00097 *----------------------------------------------------------------------------*/ 00098 00099 #define EEPROM_WDATA_8_BIT(n) ((n) & 0x000000FF) 00100 #define EEPROM_WDATA_16_BIT(n) ((n) & 0x0000FFFF) 00101 #define EEPROM_WDATA_32_BIT(n) ((n) & 0xFFFFFFFF) 00102 00103 00104 /*----------------------------------------------------------------------------* 00105 Macro defines for EEPROM read data register 00106 *----------------------------------------------------------------------------*/ 00107 00108 #define EEPROM_RDATA_8_BIT(n) ((n) & 0x000000FF) 00109 #define EEPROM_RDATA_16_BIT(n) ((n) & 0x0000FFFF) 00110 #define EEPROM_RDATA_32_BIT(n) ((n) & 0xFFFFFFFF) 00111 00112 00113 /*----------------------------------------------------------------------------* 00114 Macro defines for EEPROM power down register 00115 *----------------------------------------------------------------------------*/ 00116 00117 #define EEPROM_PWRDWN _BV(0) 00118 00119 #define EEPROM_ENDOF_RW 26 00120 #define EEPROM_ENDOF_PROG 28 00121 00122 /*----------------------------------------------------------------------------* 00123 Public functions 00124 *----------------------------------------------------------------------------*/ 00125 00126 void Lpc177x_8x_EepromInit(void); 00127 int Lpc177x_8x_EepromRead(uint16_t addr, void* buff, size_t size); 00128 int Lpc177x_8x_EepromWrite(uint16_t addr, const void* buff, size_t size); 00129 00130 #endif /* _LPC177X_8X_EEPROM_H_ */ 00131 00132 00133 00134