Skip to content

Commit d21737a

Browse files
committed
daplink_flash: Add erase flash example.
1 parent 767483d commit d21737a

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""Erase all data from the flash memory."""
2+
3+
from machine import I2C
4+
from time import sleep_ms
5+
from daplink_flash import DaplinkFlash
6+
7+
i2c = I2C(1)
8+
flash = DaplinkFlash(i2c)
9+
10+
name, ext = flash.get_filename()
11+
print("Current file: {}.{}".format(name, ext))
12+
13+
print("Erasing flash...")
14+
flash.clear_flash()
15+
sleep_ms(1000)
16+
17+
print("Done. Flash is empty.")
18+
print("ERROR: 0x{:02X}".format(flash._error()))

0 commit comments

Comments
 (0)