- /* Update count and addr for next operation */
- count -= size;
- buf = ((const char *)buf) + size;
- }
-
- /* Restore previous seek position */
- fd->fd.seek_pos = prev_seek;
- return result;
-}
-
-/**
- * Erase specified part of eeprom, writing 0xFF.
- *
- * \a addr starting address
- * \a count length of block to erase
- * \note Seek position is unchanged.
- * \return true if ok, false otherwise.
- */
-bool eeprom_erase(Eeprom *fd, e2addr_t addr, e2_size_t count)
-{
- e2blk_size_t blk_size = mem_info[fd->type].blk_size;
- uint8_t buf[blk_size];
- kfile_off_t prev_off = fd->fd.seek_pos;
- bool res = true;
- size_t size;
-
- memset(buf, 0xFF, blk_size);
-
-
- kfile_seek(&fd->fd, addr, KSM_SEEK_SET);
-
- /*
- * Optimization: this first write id used to realign
- * current address to block boundaries.
- */
-
- wdt_reset();
- size = MIN(count, (e2_size_t)(blk_size - (addr & (blk_size - 1))));
- if (kfile_write(&fd->fd, buf, size) != size)
- {
- fd->fd.seek_pos = prev_off;
- return false;
- }
- count -= size;
-
- /* Clear all */
- while (count)
- {
- /* Long operation, reset watchdog */
- wdt_reset();
-
- size = MIN(count, (e2_size_t)sizeof buf);
- if (kfile_write(&fd->fd, buf, size) != size)