spiFlash: added FlashDataSection to handle bitstream per sections when gap or 0xff area are present
This commit is contained in:
parent
7ed4954c91
commit
e302bb6edc
|
|
@ -12,6 +12,32 @@
|
||||||
#include "spiInterface.hpp"
|
#include "spiInterface.hpp"
|
||||||
#include "spiFlashdb.hpp"
|
#include "spiFlashdb.hpp"
|
||||||
|
|
||||||
|
/* Flash memory section record
|
||||||
|
* one instance per section when the bitstream contains gap
|
||||||
|
*/
|
||||||
|
class FlashDataSection {
|
||||||
|
public:
|
||||||
|
explicit FlashDataSection(uint32_t start_addr):_start_addr(start_addr) {}
|
||||||
|
|
||||||
|
/* append data set to existing */
|
||||||
|
void append(const uint8_t *data, size_t length) {
|
||||||
|
if (data && length > 0)
|
||||||
|
_record.insert(_record.end(), data, data + length);
|
||||||
|
}
|
||||||
|
/* Return section start addr */
|
||||||
|
uint32_t getStartAddr() const noexcept { return _start_addr; }
|
||||||
|
/* Return last data addr */
|
||||||
|
uint32_t getCurrentAddr() const noexcept { return _start_addr + static_cast<uint32_t>(_record.size()); }
|
||||||
|
/* Return section length */
|
||||||
|
size_t getLength() const noexcept { return _record.size(); }
|
||||||
|
/* Return section data set */
|
||||||
|
const std::vector<uint8_t> &getRecord() const noexcept { return _record; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint32_t _start_addr; // Section Start Address
|
||||||
|
std::vector<uint8_t> _record; // Data set
|
||||||
|
};
|
||||||
|
|
||||||
class SPIFlash {
|
class SPIFlash {
|
||||||
public:
|
public:
|
||||||
SPIFlash(SPIInterface *spi, bool unprotect, int8_t verbose);
|
SPIFlash(SPIInterface *spi, bool unprotect, int8_t verbose);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue