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

Function xs_flash_readString

modules/files/flash/esp/flash.c:126–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124}
125
126void xs_flash_readString(xsMachine *the)
127{
128 modFlash flash;
129 int offset = xsmcToInteger(xsArg(0));
130 int byteLength = xsmcToInteger(xsArg(1));
131 uint8_t *buffer;
132
133 flash = xsmcGetHostChunk(xsThis);
134 if ((offset < 0) || (offset >= flash->partitionByteLength))
135 xsUnknownError("invalid offset");
136
137 if ((byteLength <= 0) || ((offset + byteLength) > flash->partitionByteLength))
138 xsUnknownError("invalid length");
139
140 xsResult = xsStringBuffer(NULL, byteLength);
141 flash = xsmcGetHostChunk(xsThis);
142 if (0 == modSPIRead(offset + flash->partitionStart, byteLength, xsmcToString(xsResult)))
143 xsUnknownError("read fail");
144}
145
146void xs_flash_write(xsMachine *the)
147{

Callers

nothing calls this directly

Calls 1

modSPIReadFunction · 0.50

Tested by

no test coverage detected