Add support for the AT 24C512 EEPROM
This commit is contained in:
parent
0d02d854ed
commit
b3018d8bf0
@ -5534,4 +5534,7 @@
|
|||||||
definition file (2013-9-11).
|
definition file (2013-9-11).
|
||||||
* arch/arm/src/sama5/sam_twi.c and .h: Framework for a SAMA5
|
* arch/arm/src/sama5/sam_twi.c and .h: Framework for a SAMA5
|
||||||
TWI driver (not much present in initial checkin) (2013-9-11).
|
TWI driver (not much present in initial checkin) (2013-9-11).
|
||||||
|
* fs/nxffs: Clean up some compilation warnings (2013-9-12)
|
||||||
|
* drivers/mtd/at24xx.c: Add support for the AT 24C512 part
|
||||||
|
(2013-9-12).
|
||||||
|
|
||||||
|
@ -67,22 +67,28 @@ config RAMMTD_FLASHSIM
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
config MTD_AT24XX
|
config MTD_AT24XX
|
||||||
bool "I2C-based AT24XX eeprom"
|
bool "I2C-based AT24xx eeprom"
|
||||||
default n
|
default n
|
||||||
select I2C
|
select I2C
|
||||||
---help---
|
---help---
|
||||||
Build support for I2C-based at24cxx EEPROM(at24c32, at24c64,
|
Build support for I2C-based AT24CXX EEPROM(at24c32, at24c64,
|
||||||
at24c128, at24c256)
|
at24c128, at24c256)
|
||||||
|
|
||||||
if MTD_AT24XX
|
if MTD_AT24XX
|
||||||
|
|
||||||
config AT24XX_SIZE
|
config AT24XX_SIZE
|
||||||
int "at24xx size(kByte)"
|
int "AT24xx size (kbit)"
|
||||||
default 64
|
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
|
config AT24XX_ADDR
|
||||||
hex "at24xx i2c address"
|
hex "AT24XX I2C address"
|
||||||
default 0x50
|
default 0x50
|
||||||
|
range 0x50 0x57
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* drivers/mtd/at24xx.c
|
* 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.
|
* Copyright (C) 2011 Li Zhuoyi. All rights reserved.
|
||||||
* Author: Li Zhuoyi <lzyy.cn@gmail.com>
|
* Author: Li Zhuoyi <lzyy.cn@gmail.com>
|
||||||
@ -81,21 +81,24 @@
|
|||||||
|
|
||||||
/* Get the part configuration based on the size configuration */
|
/* 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_NPAGES 128
|
||||||
# define AT24XX_PAGESIZE 32
|
# 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_NPAGES 192
|
||||||
# define AT24XX_PAGESIZE 32
|
# 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_NPAGES 256
|
||||||
# define AT24XX_PAGESIZE 32
|
# 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_NPAGES 256
|
||||||
# define AT24XX_PAGESIZE 64
|
# 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_NPAGES 512
|
||||||
# define AT24XX_PAGESIZE 64
|
# define AT24XX_PAGESIZE 64
|
||||||
|
#elif CONFIG_AT24XX_SIZE == 512 /* AT24C512: 512Kbits = 64KiB; 512 * 128 = 65536 */
|
||||||
|
# define AT24XX_NPAGES 512
|
||||||
|
# define AT24XX_PAGESIZE 128
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* For applications where a file system is used on the AT24, the tiny page sizes
|
/* 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);
|
size_t nblocks, FAR uint8_t *buf);
|
||||||
static ssize_t at24c_bwrite(FAR struct mtd_dev_s *dev, off_t startblock,
|
static ssize_t at24c_bwrite(FAR struct mtd_dev_s *dev, off_t startblock,
|
||||||
size_t nblocks, FAR const uint8_t *buf);
|
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,
|
static ssize_t at24c_read(FAR struct mtd_dev_s *dev, off_t offset,
|
||||||
size_t nbytes,FAR uint8_t *buffer);
|
size_t nbytes,FAR uint8_t *buffer);
|
||||||
|
#endif
|
||||||
static int at24c_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg);
|
static int at24c_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg);
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
|
Loading…
Reference in New Issue
Block a user