ProgMem.h
Go to the documentation of this file.
1 /****
2  * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development.
3  * Created 2015 by Skurydin Alexey
4  * http://github.com/SmingHub/Sming
5  * All files of the Sming Core are provided under the LGPL v3 license.
6  *
7  * ProgMem.h
8  *
9  ****/
10 #pragma once
11 
12 #include "Device.h"
13 
14 namespace Storage
15 {
19 class ProgMem : public Device
20 {
21 public:
22  String getName() const override
23  {
24  return F("ProgMem");
25  }
26 
27  size_t getBlockSize() const override
28  {
29  return sizeof(uint32_t);
30  }
31 
32  storage_size_t getSize() const override
33  {
34  return 0x80000000;
35  }
36 
37  Type getType() const override
38  {
39  return Type::flash;
40  }
41 
42  bool read(storage_size_t address, void* dst, size_t size) override;
43 
44  bool write(storage_size_t address, const void* src, size_t size) override
45  {
46  return false;
47  }
48 
49  bool erase_range(storage_size_t address, storage_size_t size) override
50  {
51  return false;
52  }
53 
55  {
56  public:
65  Partition add(const String& name, const void* flashPtr, size_t size, Partition::FullType type);
66 
70  Partition add(const String& name, const FSTR::ObjectBase& fstr, Partition::FullType type)
71  {
72  return add(name, fstr.data(), fstr.size(), type);
73  }
74  };
75 
76  ProgMemPartitionTable& editablePartitions()
77  {
78  return static_cast<ProgMemPartitionTable&>(mPartitions);
79  }
80 };
81 
82 extern ProgMem progMem;
83 
84 } // namespace Storage
Represents a flash partition.
Definition: Partition.h:85
storage_size_t getSize() const override
Obtain addressable size of this device.
Definition: ProgMem.h:48
PartitionTable mPartitions
Definition: Components/Storage/src/include/Storage/Device.h:187
The String class.
Definition: WString.h:136
Definition: PartitionTable.h:26
Type
Storage type.
Definition: Components/Storage/src/include/Storage/Device.h:42
Used when defining data structures.
Definition: ObjectBase.hpp:51
Type getType() const override
Obtain device type.
Definition: ProgMem.h:53
Definition: FileDevice.h:25
Express both partition type and subtype together.
Definition: Partition.h:139
ProgMem progMem
size_t size() const
Get the object data size in bytes.
Definition: ObjectBase.hpp:82
ProgMemPartitionTable & editablePartitions()
Definition: ProgMem.h:92
bool write(storage_size_t address, const void *src, size_t size) override
Write data to the storage device.
Definition: ProgMem.h:60
Partition add(const String &name, const void *flashPtr, size_t size, Partition::FullType type)
Add partition entry for PROGMEM data access.
String getName() const override
Obtain unique device name.
Definition: ProgMem.h:38
bool erase_range(storage_size_t address, storage_size_t size) override
Erase a region of storage in preparation for writing.
Definition: ProgMem.h:65
size_t getBlockSize() const override
Obtain smallest allocation unit for erase operations.
Definition: ProgMem.h:43
bool read(storage_size_t address, void *dst, size_t size) override
Read data from the storage device.
#define F(string_literal)
Wrap a string literal stored in flash and access it using a String object.
Definition: WString.h:113
uint32_t storage_size_t
Definition: Components/Storage/src/include/Storage/Types.h:19
const uint8_t * data() const
Get a pointer to the flash data.