Skip to content

File Flash.h

File List > arduino > libraries > inline > Flash > Flash.h

Go to the documentation of this file.

/* Copyright (c) Kuba Szczodrzyński 2022-04-24. */

#pragma once

#include <Arduino.h>

#ifdef __cplusplus

class FlashClass {
  public:
    inline FlashId getChipId() { return lt_flash_get_id(); }

    inline uint32_t getSize() { return lt_flash_get_size(); }

    inline bool eraseSector(uint32_t offset) {
        //
        return lt_flash_erase_block(offset);
    }

    inline bool readBlock(uint32_t offset, uint8_t *data, size_t length) {
        //
        return lt_flash_read(offset, data, length) == length;
    }

    inline bool writeBlock(uint32_t offset, const uint8_t *data, size_t length) {
        //
        return lt_flash_write(offset, data, length) == length;
    }
};

extern FlashClass Flash;

#endif