net/fram.h File Reference

FRAM Module for reading and writing from and to the FRAM. More...


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)


Detailed Description

FRAM Module for reading and writing from and to the FRAM.

Author:
Ziggurat29
Compiler:
MPLAB C18 v2.10 or higher
HITECH PICC-18 V8.35PL3 or higher

Description

This module contains code for reading and writing from and to the FRAM, like the FM64640 or FM64256.

Configuration

The following defines are used to configure this module, and should be placed in the projdefs.h (or similar) file. For details, see Project Configuration. To configure the module, the required defines should be uncommended, and the rest commented out.
//*********************************************************************
//--------------------  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

Typedef Documentation

typedef WORD FRAM_ADDR


Function Documentation

void FRAMBeginRead ( FRAM_ADDR  addr  ) 

Sets up FRAM for reading.

Parameters:
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.

Parameters:
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.

Returns:
Read byte

void FRAMReadArr ( FRAM_ADDR  addr,
BYTE abyData,
int  nLen 
)

Read a contiguous chunk of data to the FRAM.

Parameters:
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().

Parameters:
byVal Value to be written

void FRAMWriteArr ( FRAM_ADDR  addr,
BYTE abyData,
int  nLen 
)

Write a contiguous chunk of data to the FRAM.

Parameters:
addr Address
abyData 
nLen 


Generated on Wed Feb 3 12:45:34 2010 for SBC65EC Web Server by  doxygen 1.5.8