MCPcopy Create free account
hub / github.com/RetiredWizard/PyDOS / flash_write

Method flash_write

mpython/extFlash/lib/spiflash.py:132–149  ·  view source on GitHub ↗
(self, addr, buf)

Source from the content-addressed store, hash-verified

130 self._cs(1)
131
132 def flash_write(self, addr, buf):
133 # Write in 256-byte chunks
134 length = len(buf)
135 pos = 0
136 mv = memoryview(buf)
137 while pos < length:
138 size = min(length - pos, self.pagesize - pos % self.pagesize)
139 self._cs(0)
140 self._write_cmd(CMD_WRITE_ENABLE)
141 self._cs(1)
142 # _write_addr() sets _cs low
143 self._write_addr(self._cmds[_PROGRAM_PAGE_INDEX], addr)
144 self._spi.write(mv[pos:pos + size])
145 self._cs(1)
146 self.wait()
147
148 addr += size
149 pos += size
150
151 def flash_erase(self, addr):
152 self._cs(0)

Callers 1

writeblocksMethod · 0.80

Calls 4

_write_cmdMethod · 0.95
_write_addrMethod · 0.95
waitMethod · 0.95
writeMethod · 0.45

Tested by

no test coverage detected