X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fdrv%2Feeprom.c;h=82fb9590f6126524ce8d63a76290df2ab1f706b9;hb=ee28b0a27ccfcf160e6cde5632bb5966608bbc90;hp=ba62b0033f7002afdd28df1af956014ef32416b0;hpb=4e4b0f5fe62bd85f3df0ef5b219a25c9b3fb45e3;p=bertos.git diff --git a/bertos/drv/eeprom.c b/bertos/drv/eeprom.c index ba62b003..82fb9590 100644 --- a/bertos/drv/eeprom.c +++ b/bertos/drv/eeprom.c @@ -82,6 +82,24 @@ static const EepromInfo mem_info[] = .blk_size = 0x10, .e2_size = 0x800, }, + { + /* 24XX32 */ + .has_dev_addr = true, + .blk_size = 0x20, + .e2_size = 0x1000, + }, + { + /* 24XX64 */ + .has_dev_addr = true, + .blk_size = 0x20, + .e2_size = 0x2000, + }, + { + /* 24XX128 */ + .has_dev_addr = true, + .blk_size = 0x40, + .e2_size = 0x4000, + }, { /* 24XX256 */ .has_dev_addr = true, @@ -181,9 +199,8 @@ static size_t eeprom_write(KBlock *blk, block_idx_t idx, const void *buf, size_t STATIC_ASSERT(countof(addr_buf) <= sizeof(e2addr_t)); - /* clamp size to memory limit (otherwise may roll back) */ - ASSERT(idx <= blk->blk_cnt); + ASSERT(idx < blk->priv.blk_start + blk->blk_cnt); size = MIN(size, blk->blk_size - offset); if (mem_info[eep->type].has_dev_addr) @@ -230,7 +247,7 @@ static size_t eeprom_readDirect(struct KBlock *_blk, block_idx_t idx, void *_buf STATIC_ASSERT(countof(addr_buf) <= sizeof(e2addr_t)); /* clamp size to memory limit (otherwise may roll back) */ - ASSERT(idx <= blk->blk.blk_cnt); + ASSERT(idx < blk->blk.priv.blk_start + blk->blk.blk_cnt); size = MIN(size, blk->blk.blk_size - offset); e2dev_addr_t dev_addr; @@ -330,6 +347,7 @@ static const KBlockVTable eeprom_unbuffered_vt = * \param type is the eeprom device we want to initialize (\see EepromType) * \param i2c context for i2c channel * \param addr is the i2c devide address (usually pins A0, A1, A2). + * \param verify enable the write check. */ void eeprom_init_5(Eeprom *eep, I2c *i2c, EepromType type, e2dev_addr_t addr, bool verify) {