Interface that provides the methods that may be used to interact with flash memory.

interface IFlashMemory {
    eraseSector(address): Promise<void>;
    getLayout(): Promise<IFlashMemoryLayout>;
    read(address, length, buffer): Promise<number>;
    write(address, length, data): Promise<number>;
}

Methods

  • Erases a single sector in System Flash memory. The sector to erase is determined based on the provided address. Any address within the sector will specify that the entire sector be erased. The sector specified must be in the acceptable range for the user area of Flash memory for the device. See the device User's Manual for Flash memory layout details.

    Parameters

    • address: number

      Byte address within the sector to erase.

    Returns Promise<void>

    • A promise that resolves when the sector has been erased.
  • Reads data from System Flash memory starting at the specified address. The address and length must both be integer multiples of the System Flash page size.

    Parameters

    • address: number

      Byte address to begin read operation.

    • length: number

      Length of data to read in bytes.

    • buffer: ArrayBuffer

      The buffer to store the data that is read.

    Returns Promise<number>

    • A promise that resolves when the data has been read indicating the number of bytes that were successfully read.
  • Writes data to System Flash memory starting at the specified address. The address and length must both be integer multiples of the System Flash page size. This method will not erase the sector prior to writing. You must use eraseSector to erase a sector prior to writing.

    Parameters

    • address: number

      Byte address to begin write operation.

    • length: number

      Length of data to write in bytes.

    • data: ArrayBuffer

      The buffer containing the data to write.

    Returns Promise<number>

    • A promise that resolves when the data has been written indicating the number of bytes that were successfully written.