diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2013-09-12 09:44:38 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2013-09-12 09:44:38 -0600 |
commit | e8e8b085701b8a2bc3effdef96affbae40eb4c4d (patch) | |
tree | d46c535f0df9bbac0211206d72343fa3c3704983 /nuttx/drivers/mtd | |
parent | 8e3618762c9118d45d7de472cf0400d5e0c1b3ca (diff) | |
download | px4-nuttx-e8e8b085701b8a2bc3effdef96affbae40eb4c4d.tar.gz px4-nuttx-e8e8b085701b8a2bc3effdef96affbae40eb4c4d.tar.bz2 px4-nuttx-e8e8b085701b8a2bc3effdef96affbae40eb4c4d.zip |
Add support for the AT 24C512 EEPROM
Diffstat (limited to 'nuttx/drivers/mtd')
-rw-r--r-- | nuttx/drivers/mtd/Kconfig | 14 | ||||
-rw-r--r-- | nuttx/drivers/mtd/at24xx.c | 17 |
2 files changed, 21 insertions, 10 deletions
diff --git a/nuttx/drivers/mtd/Kconfig b/nuttx/drivers/mtd/Kconfig index 01d488cd6..ffe7ac06e 100644 --- a/nuttx/drivers/mtd/Kconfig +++ b/nuttx/drivers/mtd/Kconfig @@ -67,22 +67,28 @@ config RAMMTD_FLASHSIM endif config MTD_AT24XX - bool "I2C-based AT24XX eeprom" + bool "I2C-based AT24xx eeprom" default n select I2C ---help--- - Build support for I2C-based at24cxx EEPROM(at24c32, at24c64, + Build support for I2C-based AT24CXX EEPROM(at24c32, at24c64, at24c128, at24c256) if MTD_AT24XX config AT24XX_SIZE - int "at24xx size(kByte)" + int "AT24xx size (kbit)" default 64 + ---help--- + This is the XX in the AT24Cxx part number. For example, if you have a + AT 24C512, then the correct value is 512. This value is also the capacity + of the part in kilobits. For example, the 24C512 supports 512 Kbits or + 512 /8 = 64 KiB. config AT24XX_ADDR - hex "at24xx i2c address" + hex "AT24XX I2C address" default 0x50 + range 0x50 0x57 endif diff --git a/nuttx/drivers/mtd/at24xx.c b/nuttx/drivers/mtd/at24xx.c index 2eb7c9af0..326c6f86b 100644 --- a/nuttx/drivers/mtd/at24xx.c +++ b/nuttx/drivers/mtd/at24xx.c @@ -1,6 +1,6 @@ /************************************************************************************ * drivers/mtd/at24xx.c - * Driver for I2C-based at24cxx EEPROM(at24c32,at24c64,at24c128,at24c256) + * Driver for I2C-based at24cxx EEPROM(at24c32,at24c64,at24c128,at24c256,at24c512) * * Copyright (C) 2011 Li Zhuoyi. All rights reserved. * Author: Li Zhuoyi <lzyy.cn@gmail.com> @@ -81,21 +81,24 @@ /* Get the part configuration based on the size configuration */ -#if CONFIG_AT24XX_SIZE == 32 +#if CONFIG_AT24XX_SIZE == 32 /* AT24C32: 32Kbits = 4KiB; 128 * 32 = 4096 */ # define AT24XX_NPAGES 128 # define AT24XX_PAGESIZE 32 -#elif CONFIG_AT24XX_SIZE == 48 +#elif CONFIG_AT24XX_SIZE == 48 /* AT24C48: 48Kbits = 6KiB; 192 * 32 = 6144 */ # define AT24XX_NPAGES 192 # define AT24XX_PAGESIZE 32 -#elif CONFIG_AT24XX_SIZE == 64 +#elif CONFIG_AT24XX_SIZE == 64 /* AT24C64: 64Kbits = 8KiB; 256 * 32 = 8192 */ # define AT24XX_NPAGES 256 # define AT24XX_PAGESIZE 32 -#elif CONFIG_AT24XX_SIZE == 128 +#elif CONFIG_AT24XX_SIZE == 128 /* AT24C128: 128Kbits = 16KiB; 256 * 64 = 16384 */ # define AT24XX_NPAGES 256 # define AT24XX_PAGESIZE 64 -#elif CONFIG_AT24XX_SIZE == 256 +#elif CONFIG_AT24XX_SIZE == 256 /* AT24C256: 256Kbits = 32KiB; 512 * 64 = 32768 */ # define AT24XX_NPAGES 512 # define AT24XX_PAGESIZE 64 +#elif CONFIG_AT24XX_SIZE == 512 /* AT24C512: 512Kbits = 64KiB; 512 * 128 = 65536 */ +# define AT24XX_NPAGES 512 +# define AT24XX_PAGESIZE 128 #endif /* For applications where a file system is used on the AT24, the tiny page sizes @@ -139,8 +142,10 @@ static ssize_t at24c_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks, FAR uint8_t *buf); static ssize_t at24c_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks, FAR const uint8_t *buf); +#if 0 /* Not implemented */ static ssize_t at24c_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes,FAR uint8_t *buffer); +#endif static int at24c_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg); /************************************************************************************ |