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 
77  {
78  return static_cast<ProgMemPartitionTable&>(mPartitions);
79  }
80 };
81 
82 extern ProgMem progMem;
83 
84 } // namespace Storage
uint32_t storage_size_t
Definition: Components/Storage/src/include/Storage/Types.h:19
#define F(string_literal)
Wrap a string literal stored in flash and access it using a String object.
Definition: WString.h:113
Used when defining data structures.
Definition: ObjectBase.hpp:33
constexpr const size_t size() const
Get the object data size in bytes.
Definition: ObjectBase.hpp:54
const uint8_t * data() const
Get a pointer to the flash data.
Represents a storage device (e.g. flash memory)
Definition: Components/Storage/src/include/Storage/Device.h:34
PartitionTable mPartitions
Definition: Components/Storage/src/include/Storage/Device.h:193
Type
Storage type.
Definition: Components/Storage/src/include/Storage/Device.h:42
Definition: PartitionTable.h:19
Represents a flash partition.
Definition: Partition.h:86
Partition add(const String &name, const void *flashPtr, size_t size, Partition::FullType type)
Add partition entry for PROGMEM data access.
Partition add(const String &name, const FSTR::ObjectBase &fstr, Partition::FullType type)
Add partition entry for FlashString data access.
Definition: ProgMem.h:70
Storage device to access PROGMEM using flash API.
Definition: ProgMem.h:20
storage_size_t getSize() const override
Obtain addressable size of this device.
Definition: ProgMem.h:32
size_t getBlockSize() const override
Obtain smallest allocation unit for erase operations.
Definition: ProgMem.h:27
String getName() const override
Obtain unique device name.
Definition: ProgMem.h:22
bool erase_range(storage_size_t address, storage_size_t size) override
Erase a region of storage in preparation for writing.
Definition: ProgMem.h:49
ProgMemPartitionTable & editablePartitions()
Definition: ProgMem.h:76
bool write(storage_size_t address, const void *src, size_t size) override
Write data to the storage device.
Definition: ProgMem.h:44
Type getType() const override
Obtain device type.
Definition: ProgMem.h:37
bool read(storage_size_t address, void *dst, size_t size) override
Read data from the storage device.
The String class.
Definition: WString.h:137
Definition: FileDevice.h:26
ProgMem progMem
Express both partition type and subtype together.
Definition: Partition.h:139