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

Function xs_flash_write

modules/files/flash/esp/flash.c:146–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144}
145
146void xs_flash_write(xsMachine *the)
147{
148 modFlash flash;
149 SpiFlashOpResult result;
150 int offset = xsmcToInteger(xsArg(0));
151 int byteLength = xsmcToInteger(xsArg(1));
152 void *buffer;
153 xsUnsignedValue bufferLength;
154
155 flash = xsmcGetHostChunk(xsThis);
156 if ((offset < 0) || (offset >= flash->partitionByteLength))
157 xsUnknownError("invalid offset");
158
159 if ((byteLength <= 0) || ((offset + byteLength) > flash->partitionByteLength))
160 xsUnknownError("invalid length");
161
162 xsmcGetBufferReadable(xsArg(2), &buffer, &bufferLength);
163 if (bufferLength < (xsUnsignedValue)byteLength)
164 xsUnknownError("invalid");
165
166 flash = xsmcGetHostChunk(xsThis);
167 if (0 == modSPIWrite(offset + flash->partitionStart, byteLength, buffer))
168 xsUnknownError("write fail");
169}
170
171void xs_flash_map(xsMachine *the)
172{

Callers

nothing calls this directly

Calls 1

modSPIWriteFunction · 0.50

Tested by

no test coverage detected