Typedefs | |
typedef WORD | FRAM_ADDR |
Functions | |
void | FRAMBeginRead (FRAM_ADDR addr) |
void | FRAMBeginWrite (FRAM_ADDR addr) |
void | FRAMEndRead (void) |
void | FRAMEndWrite (void) |
void | FRAMInit (void) |
BYTE | FRAMRead (void) |
void | FRAMReadArr (FRAM_ADDR addr, BYTE *abyData, int nLen) |
void | FRAMWrite (BYTE byVal) |
void | FRAMWriteArr (FRAM_ADDR addr, BYTE *abyData, int nLen) |
//********************************************************************* //-------------------- FRAM System Configuration -------------------- //********************************************************************* //this may work with either a 'true' hardware SPI, or a 'bitbang' software //SPI implementation. If you uncomment the following, the software //implementation will be used. //#define SOFTWARE_SPI 1 //the following defines which IO pins are used for the various SPI //signals to the FRAM. You can change them to suit your configuration. //IO pin definitions; //f.7 is CS //d.4 is SO //d.5 is SI //d.6 is CK #define FRAM_SPI_BIT_CS PORTF_RF7 #define FRAM_SPI_TRI_CS TRISF_RF7 #define FRAM_SPI_BIT_SI PORTD_RD5 #define FRAM_SPI_TRI_SI TRISD_RD5 #define FRAM_SPI_BIT_SO PORTD_RD4 #define FRAM_SPI_TRI_SO TRISD_RD4 #define FRAM_SPI_BIT_SCK PORTD_RD6 #define FRAM_SPI_TRI_SCK TRISD_RD6 //clock speed (only relevant for hardware SPI) //SPI_FOSC_xx depends on device and clock speed //using SPI_FOSC_16 will provide a 2.5 MHz clock (for FM25640-G) //using SPI_FOSC_4 will provide a 10 MHz clock (for FM25256-G) #define SPI_ROLE SPI_FOSC_4 //#define SPI_ROLE SPI_FOSC_16
void FRAMBeginRead | ( | FRAM_ADDR | addr | ) |
Sets up FRAM for reading.
addr | Address at which read is to be performed. |
void FRAMBeginWrite | ( | FRAM_ADDR | addr | ) |
Sets up FRAM for writing.
Remember that the SPI IO uses the same pins as the ethernet controller (unless you change that). So between the Begin() and End() calls you may _not_ do anything with the ethernet.
addr | address to where to write |
void FRAMEndRead | ( | void | ) |
Ends sequential read cycle.
void FRAMEndWrite | ( | void | ) |
End writing to FRAM.
void FRAMInit | ( | void | ) |
Call once to setup IO lines and do initial configuration of SPI (mode and data rate) for subsequent
BYTE FRAMRead | ( | void | ) |
Reads next byte from FRAM; internal address is incremented by one.
Read a contiguous chunk of data to the FRAM.
addr | Address | |
abyData | ||
nLen |
void FRAMWrite | ( | BYTE | byVal | ) |
Writes given value 'byVal' at current address. Current address is set by FRAMBeginWrite() and is incremented by every FRAMWrite().
byVal | Value to be written |
Write a contiguous chunk of data to the FRAM.
addr | Address | |
abyData | ||
nLen |