Arduino-Storage
External Memory Storage library for Arduino
MC23LCXXX< KBYTE, SS_PIN, FREQ > Class Template Reference

#include <MC23LCXXX.h>

Inheritance diagram for MC23LCXXX< KBYTE, SS_PIN, FREQ >:
Inheritance graph
Collaboration diagram for MC23LCXXX< KBYTE, SS_PIN, FREQ >:
Collaboration graph

Classes

struct  header_t
 

Public Member Functions

 MC23LCXXX (SPI &spi)
 
virtual int read (void *dst, uint32_t src, size_t count)
 
virtual int write (uint32_t dst, const void *src, size_t count)
 
uint32_t room ()
 
uint32_t alloc (size_t count)
 
void free (uint32_t addr)
 

Public Attributes

const uint32_t SIZE
 

Static Public Attributes

static const uint32_t MAX_FREQ = 16000000L
 

Protected Types

enum  { READ = 0x03, WRITE = 0x02, RDMR = 0x05, WRMR = 0x01 }
 

Protected Attributes

uint32_t m_addr
 

Detailed Description

template<uint16_t KBYTE, BOARD::pin_t SS_PIN, uint32_t FREQ = 16000000L>
class MC23LCXXX< KBYTE, SS_PIN, FREQ >

Storage device driver for Microchip 23LCXXX, SPI Serial SRAM.

Parameters
[in]KBYTEsize.
[in]SS_PINslave select board pin.
[in]FREQmax bus frequency for device (default 16 MHz).

Definition at line 32 of file MC23LCXXX.h.

Member Enumeration Documentation

template<uint16_t KBYTE, BOARD::pin_t SS_PIN, uint32_t FREQ = 16000000L>
anonymous enum
protected

Command codes.

Enumerator
READ 

Read data from memory.

WRITE 

Write data to memory.

RDMR 

Read mode register.

WRMR 

Write mode register.

Definition at line 125 of file MC23LCXXX.h.

Constructor & Destructor Documentation

template<uint16_t KBYTE, BOARD::pin_t SS_PIN, uint32_t FREQ = 16000000L>
MC23LCXXX< KBYTE, SS_PIN, FREQ >::MC23LCXXX ( SPI &  spi)
inline

Construct and initiate device driver with given slave select board pin, max bus frequency, and bus manager.

Parameters
[in]spibus manager.

Definition at line 44 of file MC23LCXXX.h.

Member Function Documentation

uint32_t Storage::alloc ( size_t  count)
inlineinherited

Allocate block with given number of bytes on storage. Returns storage address if successful otherwise UINT32_MAX.

Parameters
[in]countnumber of bytes.
Returns
address of allocated block, otherwise UINT32_MAX.

Definition at line 53 of file Storage.h.

void Storage::free ( uint32_t  addr)
inlineinherited

Reset allocation point to given address.

Parameters
[in]addraddress of allocated block.

Definition at line 65 of file Storage.h.

template<uint16_t KBYTE, BOARD::pin_t SS_PIN, uint32_t FREQ = 16000000L>
virtual int MC23LCXXX< KBYTE, SS_PIN, FREQ >::read ( void *  dst,
uint32_t  src,
size_t  count 
)
inlinevirtual

Read given count number of bytes from SRAM source address to destination buffer. Returns number of bytes read, or negative error code.

Parameters
[in]dstdestination buffer pointer.
[in]srcsource memory address on device.
[in]countnumber of bytes to read from device.
Returns
number of bytes read or negative error code.

Implements Storage.

Definition at line 59 of file MC23LCXXX.h.

uint32_t Storage::room ( )
inlineinherited

Returns number of bytes that may be allocated.

Returns
number of bytes.

Definition at line 42 of file Storage.h.

template<uint16_t KBYTE, BOARD::pin_t SS_PIN, uint32_t FREQ = 16000000L>
virtual int MC23LCXXX< KBYTE, SS_PIN, FREQ >::write ( uint32_t  dst,
const void *  src,
size_t  count 
)
inlinevirtual

Write given count number of bytes to SRAM destination address from source buffer. Returns number of bytes written, or negative error code.

Parameters
[in]dstdestination memory address on device.
[in]srcsource buffer pointer.
[in]countnumber of bytes to write to device.
Returns
number of bytes written or negative error code.

Implements Storage.

Definition at line 93 of file MC23LCXXX.h.

Member Data Documentation

uint32_t Storage::m_addr
protectedinherited

Address of the next allocation.

Definition at line 398 of file Storage.h.

template<uint16_t KBYTE, BOARD::pin_t SS_PIN, uint32_t FREQ = 16000000L>
const uint32_t MC23LCXXX< KBYTE, SS_PIN, FREQ >::MAX_FREQ = 16000000L
static

Maximum device clock frequency.

Definition at line 37 of file MC23LCXXX.h.

const uint32_t Storage::SIZE
inherited

Number of bytes on device.

Definition at line 30 of file Storage.h.


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