Skip to content
This repository has been archived by the owner on Jan 7, 2019. It is now read-only.

Commit

Permalink
[driver] block device: expose DeviceSize
Browse files Browse the repository at this point in the history
  • Loading branch information
rleh committed Jan 28, 2018
1 parent f4e91b3 commit e068490
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/xpcc/architecture/interface/block_device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class BlockDevice
static constexpr bd_size_t BlockSizeRead = 1;
static constexpr bd_size_t BlockSizeWrite = 1;
static constexpr bd_size_t BlockSizeErase = 1;
static constexpr bd_size_t BlockDevice = 1024;

#endif
};
Expand Down
3 changes: 2 additions & 1 deletion src/xpcc/driver/storage/block_device_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace xpcc
* \ingroup driver_storage
* \author Raphael Lehmann
*/
template <class Filename, size_t DeviceSize>
template <class Filename, size_t DeviceSize_>
class BdFile : public xpcc::BlockDevice, protected xpcc::NestedResumable<3>
{
public:
Expand Down Expand Up @@ -89,6 +89,7 @@ class BdFile : public xpcc::BlockDevice, protected xpcc::NestedResumable<3>
static constexpr bd_size_t BlockSizeRead = 1;
static constexpr bd_size_t BlockSizeWrite = 1;
static constexpr bd_size_t BlockSizeErase = 1;
static constexpr bd_size_t DeviceSize = DeviceSize_;
private:
std::fstream file;
};
Expand Down
3 changes: 2 additions & 1 deletion src/xpcc/driver/storage/block_device_heap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace xpcc
* \ingroup driver_storage
* \author Raphael Lehmann
*/
template <size_t DeviceSize, bool externalMemory = false>
template <size_t DeviceSize_, bool externalMemory = false>
class BdHeap : public xpcc::BlockDevice, protected xpcc::NestedResumable<3>
{
public:
Expand Down Expand Up @@ -94,6 +94,7 @@ class BdHeap : public xpcc::BlockDevice, protected xpcc::NestedResumable<3>
static constexpr bd_size_t BlockSizeRead = 1;
static constexpr bd_size_t BlockSizeWrite = 1;
static constexpr bd_size_t BlockSizeErase = 1;
static constexpr bd_size_t DeviceSize = DeviceSize_;

public:
void
Expand Down
1 change: 1 addition & 0 deletions src/xpcc/driver/storage/block_device_mirror.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class BdMirror : public xpcc::BlockDevice, protected NestedResumable<3>
static constexpr bd_size_t BlockSizeRead = BlockDeviceA::BlockSizeRead;
static constexpr bd_size_t BlockSizeWrite = std::max(BlockDeviceA::BlockSizeWrite, BlockDeviceB::BlockSizeWrite);
static constexpr bd_size_t BlockSizeErase = std::max(BlockDeviceA::BlockSizeErase, BlockDeviceB::BlockSizeErase);
static constexpr bd_size_t DeviceSize = std::min(BlockDeviceA::DeviceSize, BlockDeviceB::DeviceSize);

public:
/** Direct access to the BlockDeviceA
Expand Down
1 change: 1 addition & 0 deletions src/xpcc/driver/storage/block_device_spiflash.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ class BdSpiFlash : public xpcc::BlockDevice, public xpcc::SpiDevice< Spi >, prot
static constexpr bd_size_t BlockSizeRead = 1;
static constexpr bd_size_t BlockSizeWrite = 256;
static constexpr bd_size_t BlockSizeErase = 4 * 1024;
static constexpr bd_size_t DeviceSize = flashSize;

private:
uint8_t instructionBuffer[7];
Expand Down

0 comments on commit e068490

Please sign in to comment.