COSA
An Object-Oriented Platform for Arduino Programming
Flash.hh
Go to the documentation of this file.
1 
21 #ifndef COSA_FLASH_HH
22 #define COSA_FLASH_HH
23 
24 #include "Cosa/Types.h"
25 
26 class Flash {
27 public:
31  class Device {
32  public:
34  const uint32_t SECTOR_BYTES;
35 
37  static const uint32_t DEFAULT_SECTOR_BYTES = 4096;
38 
40  const uint32_t SECTOR_MASK;
41 
43  const uint16_t SECTOR_MAX;
44 
46  const uint32_t DEVICE_BYTES;
47 
54  Device(uint32_t bytes, uint16_t count) :
55  SECTOR_BYTES(bytes),
56  SECTOR_MASK(bytes - 1),
57  SECTOR_MAX(count),
58  DEVICE_BYTES(count * bytes)
59  {}
60 
67  virtual bool begin()
68  {
69  return (true);
70  }
71 
78  virtual bool end()
79  {
80  return (true);
81  }
82 
89  virtual bool is_ready() = 0;
90 
101  virtual int read(void* dest, uint32_t src, size_t size) = 0;
102 
113  virtual int erase(uint32_t dest, uint8_t size) = 0;
114 
125  virtual int write(uint32_t dest, const void* src, size_t size) = 0;
126 
137  virtual int write_P(uint32_t dest, const void* scr, size_t size) = 0;
138  };
139 };
140 
141 #endif
virtual bool begin()
Definition: Flash.hh:67
virtual int write(uint32_t dest, const void *src, size_t size)=0
virtual int read(void *dest, uint32_t src, size_t size)=0
virtual bool end()
Definition: Flash.hh:78
virtual int erase(uint32_t dest, uint8_t size)=0
const uint16_t SECTOR_MAX
Definition: Flash.hh:43
const uint32_t SECTOR_BYTES
Definition: Flash.hh:34
const uint32_t DEVICE_BYTES
Definition: Flash.hh:46
Definition: Flash.hh:26
static const uint32_t DEFAULT_SECTOR_BYTES
Definition: Flash.hh:37
virtual bool is_ready()=0
virtual int write_P(uint32_t dest, const void *scr, size_t size)=0
Device(uint32_t bytes, uint16_t count)
Definition: Flash.hh:54
const uint32_t SECTOR_MASK
Definition: Flash.hh:40