/* ################################################################### ** This component module is generated by Processor Expert. Do not modify it. ** Filename : McuEE24.h ** Project : FRDM-K64F_Generator ** Processor : MK64FN1M0VLL12 ** Component : 24AA_EEPROM ** Version : Component 01.042, Driver 01.00, CPU db: 3.00.000 ** Compiler : GNU C Compiler ** Date/Time : 2021-04-18, 20:37, # CodeGen: 733 ** Abstract : ** Driver for Microchip 24_AA/LC EEPROMs ** Settings : ** Component name : McuEE24 ** SDK : McuLib ** Device Type : 8 ** Initial I2C Device Address Bits : 0x0 ** Block buffer size : 32 ** Acknowledge Polling : Enabled ** Page Write Time (ms) : 5 ** Wait : McuWait ** ACK Polling Time (us) : 100 ** Connection : ** I2C : McuGenericI2C ** Write Protection Pin : Enabled ** WP : SDK_BitIO ** Timeout : Enabled ** Timeout : McuTimeout ** Timeout Byte (ms) : 10 ** Timeout Block (ms) : 60 ** Shell : Enabled ** Shell : McuShell ** Utility : McuUtility ** Contents : ** ReadByte - uint8_t McuEE24_ReadByte(McuEE24_Address addr, uint8_t *data); ** WriteByte - uint8_t McuEE24_WriteByte(McuEE24_Address addr, uint8_t data); ** ReadBlock - uint8_t McuEE24_ReadBlock(McuEE24_Address addr, uint8_t *data, uint16_t... ** WriteBlock - uint8_t McuEE24_WriteBlock(McuEE24_Address addr, uint8_t *data, uint16_t... ** WriteProtect - void McuEE24_WriteProtect(void); ** WriteUnprotect - void McuEE24_WriteUnprotect(void); ** SelectDevice - uint8_t McuEE24_SelectDevice(uint8_t addrI2C); ** GetSelectedDevice - uint8_t McuEE24_GetSelectedDevice(void); ** Test - uint8_t McuEE24_Test(void); ** ParseCommand - uint8_t McuEE24_ParseCommand(const unsigned char *cmd, bool *handled, const... ** Deinit - void McuEE24_Deinit(void); ** Init - void McuEE24_Init(void); ** ** * Copyright (c) 2013-2021, Erich Styger ** * Web: https://mcuoneclipse.com ** * SourceForge: https://sourceforge.net/projects/mcuoneclipse ** * Git: https://github.com/ErichStyger/McuOnEclipse_PEx ** * All rights reserved. ** * ** * Redistribution and use in source and binary forms, with or without modification, ** * are permitted provided that the following conditions are met: ** * ** * - Redistributions of source code must retain the above copyright notice, this list ** * of conditions and the following disclaimer. ** * ** * - Redistributions in binary form must reproduce the above copyright notice, this ** * list of conditions and the following disclaimer in the documentation and/or ** * other materials provided with the distribution. ** * ** * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ** * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ** * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ** * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ** * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ** * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; ** * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ** * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ** * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ** ###################################################################*/ /*! ** @file McuEE24.h ** @version 01.00 ** @brief ** Driver for Microchip 24_AA/LC EEPROMs */ /*! ** @addtogroup McuEE24_module McuEE24 module documentation ** @{ */ #ifndef __McuEE24_H #define __McuEE24_H /* MODULE McuEE24. */ #include "McuLib.h" /* SDK and API used */ #include "McuEE24config.h" /* configuration */ #if McuEE24_CONFIG_USE_SHELL #include "McuShell.h" #endif #if McuEE24_CONFIG_DEVICE_ID==8 #define McuEE24_MAX_I2C_ADDR_MASK 0 /* A2|A1|A0 are not used */ #define McuEE24_MAX_ADDRESS 0x03FF /* 8 kBit is 1KByte */ #define McuEE24_ADDRT uint16_t /* a word/16bit is enough to hold the address */ #define McuEE24_PAGE_SIZE 16 /* maximum page size (for page/block operation) */ #elif McuEE24_CONFIG_DEVICE_ID==16 #define McuEE24_MAX_I2C_ADDR_MASK 0 /* A2|A1|A0 are not used */ #define McuEE24_MAX_ADDRESS 0x07FF /* 16 kBit is 2KByte */ #define McuEE24_ADDRT uint16_t /* a word/16bit is enough to hold the address */ #define McuEE24_PAGE_SIZE 16 /* maximum page size (for page/block operation) */ #elif McuEE24_CONFIG_DEVICE_ID==32 #define McuEE24_MAX_I2C_ADDR_MASK 7 /* A2|A1|A0 form the I2C device address => address cannot be more than 7 (8 devices) */ #define McuEE24_MAX_ADDRESS 0x0FFF /* 32 kBit are 4KByte */ #define McuEE24_ADDRT uint16_t /* a word/16bit is enough to hold the address */ #define McuEE24_PAGE_SIZE 8 /* maximum page size (for page/block operation) */ #elif McuEE24_CONFIG_DEVICE_ID==256 #define McuEE24_MAX_I2C_ADDR_MASK 7 /* A2|A1|A0 form the I2C device address => address cannot be more than 7 (8 devices) */ #define McuEE24_MAX_ADDRESS 0x7FFF /* 256 kBit are 32KByte */ #define McuEE24_ADDRT uint16_t /* a word/16bit is enough to hold the address */ #define McuEE24_PAGE_SIZE 64 /* maximum page size (for page/block operation) */ #elif McuEE24_CONFIG_DEVICE_ID==512 #define McuEE24_MAX_I2C_ADDR_MASK 7 /* A2|A1|A0 form the I2C device address => address cannot be more than 7 (8 devices) */ #define McuEE24_MAX_ADDRESS 0xFFFF /* 512 kBit are 64KByte */ #define McuEE24_ADDRT uint16_t /* a word/16bit is enough to hold the address */ #define McuEE24_PAGE_SIZE 128 /* maximum page size (for page/block operation) */ #elif McuEE24_CONFIG_DEVICE_ID==1025 #define McuEE24_MAX_I2C_ADDR_MASK 3 /* A1|A0 form the I2C device address => address cannot be more than 3 (4 devices) */ #define McuEE24_MAX_ADDRESS 0x1FFFF /* 1024 kBit are 128KByte */ #define McuEE24_ADDRT uint32_t /* a longword/32bit is needed to hold the address */ #define McuEE24_PAGE_SIZE 128 /* maximum page size (for page/block operation) */ #else #error "unknown device?" #endif #ifndef __BWUserType_McuEE24_Address #define __BWUserType_McuEE24_Address typedef McuEE24_ADDRT McuEE24_Address; /* A type large enought to hold the address, depending on the EEPROM used. */ #endif #define McuEE24_PARSE_COMMAND_ENABLED 1 /* set to 1 if method ParseCommand() is present, 0 otherwise */ uint8_t McuEE24_WriteByte(McuEE24_Address addr, uint8_t data); /* ** =================================================================== ** Method : WriteByte (component 24AA_EEPROM) ** ** Description : ** Writes a single byte to specified address ** Parameters : ** NAME - DESCRIPTION ** addr - The address inside the EEPROM ** data - The data value to write ** Returns : ** --- - Error code, possible values ** ERR_OK - OK ** otherwise it can return an error code of ** the underlying communication protocol. ** =================================================================== */ uint8_t McuEE24_ReadByte(McuEE24_Address addr, uint8_t *data); /* ** =================================================================== ** Method : ReadByte (component 24AA_EEPROM) ** ** Description : ** Reads a single byte from the given memory address ** Parameters : ** NAME - DESCRIPTION ** addr - The address where to read from memory. ** * data - Pointer to a location where to store the ** data ** Returns : ** --- - Error code, possible values ** ERR_OK - OK ** otherwise it can return an error code of ** the underlying communication protocol. ** =================================================================== */ uint8_t McuEE24_ReadBlock(McuEE24_Address addr, uint8_t *data, uint16_t dataSize); /* ** =================================================================== ** Method : ReadBlock (component 24AA_EEPROM) ** ** Description : ** Read a block of memory. ** Parameters : ** NAME - DESCRIPTION ** addr - Address where to read the memory ** * data - Pointer to a buffer where to store the ** data ** dataSize - Size of buffer the data pointer ** is pointing to ** Returns : ** --- - Error code, possible values ** ERR_OK - OK ** otherwise it can return an error code of ** the underlying communication protocol. ** =================================================================== */ uint8_t McuEE24_WriteBlock(McuEE24_Address addr, uint8_t *data, uint16_t dataSize); /* ** =================================================================== ** Method : WriteBlock (component 24AA_EEPROM) ** ** Description : ** Writes a block of data to the EEPROM ** Parameters : ** NAME - DESCRIPTION ** addr - Address of memory ** * data - Pointer to the data ** dataSize - Size of data ** Returns : ** --- - Error code, possible values ** ERR_OK - OK ** ERR_OVERFLOW - data block passed has either ** size of zero or exceeds internal buffer ** size ** otherwise it can return an error code of ** the underlying communication protocol. ** =================================================================== */ uint8_t McuEE24_Test(void); /* ** =================================================================== ** Method : Test (component 24AA_EEPROM) ** ** Description : ** Test routine to test the driver. Note that this routine ** writes to the EEPROM! ** Parameters : None ** Returns : ** --- - Error code, possible values ** ERR_OK - OK ** ERR_FAULT - Test failed ** =================================================================== */ void McuEE24_WriteProtect(void); /* ** =================================================================== ** Method : WriteProtect (component 24AA_EEPROM) ** ** Description : ** Prevents writing to the memory. Read operations are not ** affected. ** Parameters : None ** Returns : Nothing ** =================================================================== */ void McuEE24_WriteUnprotect(void); /* ** =================================================================== ** Method : WriteUnprotect (component 24AA_EEPROM) ** ** Description : ** Allows writing to the memory ** Parameters : None ** Returns : Nothing ** =================================================================== */ uint8_t McuEE24_SelectDevice(uint8_t addrI2C); /* ** =================================================================== ** Method : SelectDevice (component 24AA_EEPROM) ** ** Description : ** Configures the I2C address to be used for the memory. With ** this multiple devices attached to the bus can be addressed. ** Parameters : ** NAME - DESCRIPTION ** addrI2C - I2C Address of the memory device, ** formed by the address pins. ** Returns : ** --- - Error code, possible codes: ** ERR_OK - OK ** ERR_VALUE - address exceeds address pins of ** device type used ** =================================================================== */ uint8_t McuEE24_ParseCommand(const unsigned char *cmd, bool *handled, const McuShell_StdIOType *io); /* ** =================================================================== ** Method : ParseCommand (component 24AA_EEPROM) ** ** Description : ** Shell Command Line parser. This method is enabled/disabled ** depending on if you have the Shell enabled/disabled in the ** properties. ** Parameters : ** NAME - DESCRIPTION ** * cmd - Pointer to command string ** * handled - Pointer to variable which tells if ** the command has been handled or not ** * io - Pointer to I/O structure ** Returns : ** --- - Error code ** =================================================================== */ uint8_t McuEE24_GetSelectedDevice(void); /* ** =================================================================== ** Method : GetSelectedDevice (component 24AA_EEPROM) ** ** Description : ** Returns the currently used I2C address (e.g. set with ** SelectDevice()). ** Parameters : None ** Returns : ** --- - I2C device address ** =================================================================== */ uint8_t McuEE24_WriteBlockPage(McuEE24_Address addr, uint8_t *data, uint16_t dataSize); /* ** =================================================================== ** Method : McuEE24_WriteBlockPage (component 24AA_EEPROM) ** ** Description : ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ void McuEE24_Deinit(void); /* ** =================================================================== ** Method : Deinit (component 24AA_EEPROM) ** ** Description : ** Driver de-initialization ** Parameters : None ** Returns : Nothing ** =================================================================== */ void McuEE24_Init(void); /* ** =================================================================== ** Method : Init (component 24AA_EEPROM) ** ** Description : ** Driver initialization ** Parameters : None ** Returns : Nothing ** =================================================================== */ /* END McuEE24. */ #endif /* ifndef __McuEE24_H */ /*! ** @} */