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

Function xs_flash_read

modules/files/flash/nrf52/flash.c:90–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90void xs_flash_read(xsMachine *the)
91{
92 int offset = xsmcToInteger(xsArg(0));
93 int byteLength = xsmcToInteger(xsArg(1));
94 modFlash flash = xsmcGetHostChunk(xsThis);
95
96 if ((offset < 0) || (offset >= flash->partitionByteLength))
97 xsUnknownError("invalid offset");
98
99 if ((byteLength <= 0) || ((offset + byteLength) > flash->partitionByteLength))
100 xsUnknownError("invalid length");
101
102 xsmcSetArrayBuffer(xsResult, NULL, byteLength);
103
104 flash = xsmcGetHostChunk(xsThis); // xsmcSetArrayBuffer may have moved the handle
105
106 if (!modSPIRead(offset + flash->partitionStart, byteLength, xsmcToArrayBuffer(xsResult)))
107 xsUnknownError("read failed");
108}
109
110void xs_flash_readString(xsMachine *the)
111{

Callers

nothing calls this directly

Calls 1

modSPIReadFunction · 0.50

Tested by

no test coverage detected