| 88 | } |
| 89 | |
| 90 | void 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 | |
| 110 | void xs_flash_readString(xsMachine *the) |
| 111 | { |
nothing calls this directly
no test coverage detected