MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / spiWrite

Function spiWrite

xs/platforms/esp/xsHost.c:1367–1383  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1365}
1366
1367static txBoolean spiWrite(void *dst, size_t offset, void *buffer, size_t size)
1368{
1369 const esp_partition_t *partition = dst;
1370
1371 if (!(offset & (kFlashSectorSize - 1))) { // if offset is at start of a sector, erase that sector
1372 int result = esp_partition_erase_range(partition, (uintptr_t)offset, (size + kFlashSectorSize - 1) & ~(kFlashSectorSize - 1));
1373 if (ESP_OK != result)
1374 return 0;
1375 }
1376
1377 if (ESP_OK != esp_partition_write(partition, (uintptr_t)offset, buffer, size)) {
1378 modLog("write fail");
1379 return 0;
1380 }
1381
1382 return 1;
1383}
1384
1385void *modInstallMods(xsMachine *the, void *preparationIn, uint8_t *status)
1386{

Callers

nothing calls this directly

Calls 2

modSPIEraseFunction · 0.70
modSPIWriteFunction · 0.70

Tested by

no test coverage detected