Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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:
-
spi An SPI object ncs Chip select pin
Definition at line 11 of file FRAMSPI.cpp.
Member Function Documentation
| char read | ( | int | addr ) |
read a byte from FRAM
- Parameters:
-
addr The 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:
-
addr The FRAM address to read from buff The buffer to read into (must be big enough!) cnt The 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:
-
addr The address SFRAM to write to data The 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:
-
addr The FRAM address write to buff The buffer to write from cnt The number of bytes to write
Definition at line 58 of file FRAMSPI.cpp.
Generated on Thu Jul 14 2022 22:53:50 by
1.7.2