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

#include <MC23LCXXX.h>

Inheritance diagram for MC23LC512< SS_PIN, FREQ >:
Inheritance graph
Collaboration diagram for MC23LC512< SS_PIN, FREQ >:
Collaboration graph

Public Member Functions

 MC23LC512 (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
 

Protected Types

enum  
 

Protected Attributes

uint32_t m_addr
 

Detailed Description

template<BOARD::pin_t SS_PIN, uint32_t FREQ = 16000000L>
class MC23LC512< SS_PIN, FREQ >

Storage device driver for Microchip 23LC512, 512 Kbit SPI Serial SRAM.

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

Circuit

23LC512
+------------+
(SS)----------------1-|CS U VCC|-8----------------(VCC)
(MISO)--------------2-|SO HOLD|-7---------(VCC/PULLUP)
(VCC/PULLUP)--------3-|NU SCK|-6----------------(SCK)
(GND)---------------4-|VSS SI|-5---------------(MOSI)
+------------+

Definition at line 156 of file MC23LCXXX.h.

Member Enumeration Documentation

anonymous enum
protectedinherited

Command codes.

Definition at line 125 of file MC23LCXXX.h.

Constructor & Destructor Documentation

template<BOARD::pin_t SS_PIN, uint32_t FREQ = 16000000L>
MC23LC512< SS_PIN, FREQ >::MC23LC512 ( 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 163 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.

virtual int MC23LCXXX< KBYTE, SS_PIN, FREQ >::read ( void *  dst,
uint32_t  src,
size_t  count 
)
inlinevirtualinherited

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.

virtual int MC23LCXXX< KBYTE, SS_PIN, FREQ >::write ( uint32_t  dst,
const void *  src,
size_t  count 
)
inlinevirtualinherited

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.

const uint32_t MC23LCXXX< KBYTE, SS_PIN, FREQ >::MAX_FREQ
staticinherited

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: