| 124 | } |
| 125 | |
| 126 | void 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 | |
| 146 | void xs_flash_write(xsMachine *the) |
| 147 | { |
nothing calls this directly
no test coverage detected