COSA
An Object-Oriented Platform for Arduino Programming
Flash::Device Class Referenceabstract

#include <Flash.hh>

Inheritance diagram for Flash::Device:
Inheritance graph
Collaboration diagram for Flash::Device:
Collaboration graph

Public Member Functions

 Device (uint32_t bytes, uint16_t count)
 
virtual bool begin ()
 
virtual bool end ()
 
virtual bool is_ready ()=0
 
virtual int read (void *dest, uint32_t src, size_t size)=0
 
virtual int erase (uint32_t dest, uint8_t size)=0
 
virtual int write (uint32_t dest, const void *src, size_t size)=0
 
virtual int write_P (uint32_t dest, const void *scr, size_t size)=0
 

Public Attributes

const uint32_t SECTOR_BYTES
 
const uint32_t SECTOR_MASK
 
const uint16_t SECTOR_MAX
 
const uint32_t DEVICE_BYTES
 

Static Public Attributes

static const uint32_t DEFAULT_SECTOR_BYTES = 4096
 

Detailed Description

Cosa Flash memory device driver interface.

Definition at line 31 of file Flash.hh.

Constructor & Destructor Documentation

Flash::Device::Device ( uint32_t  bytes,
uint16_t  count 
)
inline

Construct flash memory device driver with given sector size and count.

Parameters
[in]sizeof sector in bytes.
[in]countnumber of sector.

Definition at line 54 of file Flash.hh.

Member Function Documentation

virtual bool Flash::Device::begin ( )
inlinevirtual

Initiate the flash memory device driver. Return true(1) if the successful otherwise false(0).

Returns
bool.

Reimplemented in S25FL127S, and W25X40CL.

Definition at line 67 of file Flash.hh.

virtual bool Flash::Device::end ( )
inlinevirtual

Terminate the flash memory device driver. Return true(1) if the successful otherwise false(0).

Returns
bool.

Definition at line 78 of file Flash.hh.

virtual int Flash::Device::erase ( uint32_t  dest,
uint8_t  size 
)
pure virtual

Erase given flash block for given byte address. The actual sector and number of bytes in sector is defined by the implementation device. Returs zero(0) if successful otherwise an negative error code(-1).

Parameters
[in]destdestination block byte address to erase.
[in]sizeof sector to erase in Kbyte.
Returns
zero or negative error code.

Implemented in S25FL127S, and W25X40CL.

virtual bool Flash::Device::is_ready ( )
pure virtual

Return true(1) if the device is ready, write cycle is completed, otherwise false(0).

Returns
bool.

Implemented in S25FL127S, and W25X40CL.

virtual int Flash::Device::read ( void *  dest,
uint32_t  src,
size_t  size 
)
pure virtual

Read flash block with the given size into the buffer from the source address. Return number of bytes read or negative error code.

Parameters
[in]destbuffer to read from flash into.
[in]srcaddress in flash to read from.
[in]sizenumber of bytes to read.
Returns
number of bytes or negative error code.

Implemented in S25FL127S, and W25X40CL.

virtual int Flash::Device::write ( uint32_t  dest,
const void *  src,
size_t  size 
)
pure virtual

Write flash block at given destination address with the contents of the source buffer. Return number of bytes written or negative error code.

Parameters
[in]destaddress in flash to write to.
[in]srcbuffer to write to flash.
[in]sizenumber of bytes to write.
Returns
number of bytes or negative error code.

Implemented in S25FL127S, and W25X40CL.

virtual int Flash::Device::write_P ( uint32_t  dest,
const void *  scr,
size_t  size 
)
pure virtual

Write flash block at given destination address with contents of the source buffer in program memory. Return number of bytes written or negative error code.

Parameters
[in]destaddress in flash to write to.
[in]srcbuffer in program memory to write to flash.
[in]sizenumber of bytes to write.
Returns
number of bytes written or EOF(-1).

Implemented in S25FL127S, and W25X40CL.

Member Data Documentation

const uint32_t Flash::Device::DEFAULT_SECTOR_BYTES = 4096
static

Default size of sector in bytes.

Definition at line 37 of file Flash.hh.

const uint32_t Flash::Device::DEVICE_BYTES

Number of bytes of device.

Definition at line 46 of file Flash.hh.

const uint32_t Flash::Device::SECTOR_BYTES

Size of sector in bytes.

Definition at line 34 of file Flash.hh.

const uint32_t Flash::Device::SECTOR_MASK

Sector address mask.

Definition at line 40 of file Flash.hh.

const uint16_t Flash::Device::SECTOR_MAX

Number of sectors.

Definition at line 43 of file Flash.hh.


The documentation for this class was generated from the following file: