x

Dependents:   20180621_FT813

Embed: (wiki syntax)

« Back to documentation index

FRAMSPI Class Reference

FRAMSPI Class Reference

An interface for the Ramtron FM25VXX FRAM over SPI. More...

#include <FRAMSPI.h>

Public Member Functions

 FRAMSPI (SPI &spi, PinName ncs)
 Create an interface.
void readID (char *buff)
 read chip 8 byte device ID
void readSN (char *buff)
 read chip 2 byte serial number
char read (int addr)
 read a byte from FRAM
void read (int addr, char *buff, int cnt)
 read multiple bytes from FRAM into a buffer
void write (int addr, char data)
 write a byte to FRAM
void write (int addr, char *buff, int cnt)
 write multiple bytes to FRAM from a buffer

Detailed Description

An interface for the Ramtron FM25VXX FRAM over SPI.

 #include "mbed.h"
 #include "FRAMSPI.h"
 
 SPI spi(p5,p6,p7);
 FRAMSPI fram(spi,p8);
 Serial pc(USBTX, USBRX);
 
 int main() {
     char wdata[] = "Hello world!";
     char rdata[14];
 
     fram.write(0, wdata, 13); // 12 symbols + zero terminator
     fram.read(0, rdata, 13);
 
     pc.printf("data: %s", rdata);
 }

connections: chip pin 1 to any GPIO. Chip select (!S) chip pin 2 SO to MISO. Write (!W) chip pin 3 to Vout or N/C chip pin 4 to Gnd chip pin 5 SI to MOSI chip pin 6 SCK to sck chip pin 7 to Vout. !Hold chip pin 8 to Vout

Definition at line 55 of file FRAMSPI.h.


Constructor & Destructor Documentation

FRAMSPI ( SPI &  spi,
PinName  ncs 
)

Create an interface.

Parameters:
spiAn SPI object
ncsChip select pin

Definition at line 11 of file FRAMSPI.cpp.


Member Function Documentation

char read ( int  addr )

read a byte from FRAM

Parameters:
addrThe address to read from
Returns:
the byte at that address

Definition at line 67 of file FRAMSPI.cpp.

void read ( int  addr,
char *  buff,
int  cnt 
)

read multiple bytes from FRAM into a buffer

Parameters:
addrThe FRAM address to read from
buffThe buffer to read into (must be big enough!)
cntThe number of bytes to read

Definition at line 75 of file FRAMSPI.cpp.

void readID ( char *  buff )

read chip 8 byte device ID

Definition at line 23 of file FRAMSPI.cpp.

void readSN ( char *  buff )

read chip 2 byte serial number

Definition at line 31 of file FRAMSPI.cpp.

void write ( int  addr,
char  data 
)

write a byte to FRAM

Parameters:
addrThe address SFRAM to write to
dataThe byte to write there

Definition at line 52 of file FRAMSPI.cpp.

void write ( int  addr,
char *  buff,
int  cnt 
)

write multiple bytes to FRAM from a buffer

Parameters:
addrThe FRAM address write to
buffThe buffer to write from
cntThe number of bytes to write

Definition at line 58 of file FRAMSPI.cpp.