Toyomasa Watarai / MB85RCxx_I2C

Dependents:   MB85RCxx_hello

Embed: (wiki syntax)

« Back to documentation index

MB85RCxx_I2C Class Reference

MB85RCxx_I2C Class Reference

Interface for accessing Fujitsu MB85RCxx FRAM. More...

#include <MB85RCxx_I2C.h>

Public Member Functions

 MB85RCxx_I2C (PinName sda, PinName scl, char slave_adr=MB85RC_I2C_ADDRESS)
 Create an MB85RCxx_I2C instance which is connected to specified I2C pins with specified address.
virtual ~MB85RCxx_I2C ()
 Destructor of MB85RCxx_I2C.
int read_device_id (char *device_id)
 Read device ID from MB85RCxx FRAM.
void read (uint32_t address, char *data, uint32_t length)
 Read data from memory address.
void write (uint32_t address, char *data, uint32_t length)
 Write data to memory address.
void write (uint32_t address, char data)
 Write data to memory address.
void fill (uint32_t address, uint8_t data, uint32_t length)
 Fill data to memory address.

Detailed Description

Interface for accessing Fujitsu MB85RCxx FRAM.

 #include "mbed.h"
 #include "MB85RCxx_I2C.h"
 
 Serial pc(USBTX, USBRX);
 
 #if defined(TARGET_LPC1768)
 MB85RCxx_I2C fram(p28, p27);
 #else
 MB85RCxx_I2C fram(D14, D15);
 #endif
 
 int main()
 {
     char buf[16];
     uint32_t address;
     
     fram.fill(0, 0, 256);
 
     for (int i = 0; i < 16; i++) {
         buf[i] = i;
     }
     fram.write(0, buf, 16);
 
     for (address = 0; address < 0x80; address += 16) {
         fram.read(address, buf, 16);
         pc.printf("%08X : ", address);
         for (int i = 0; i < 16; i++) {
             pc.printf("%02X ", buf[i]);    
         }
         pc.printf("\n");
     }
 }

MB85RCxx_I2C class

MB85RCxx_I2C: A library to access Fujitsu MB85RCxx_I2C FRAM

Definition at line 88 of file MB85RCxx_I2C.h.


Constructor & Destructor Documentation

MB85RCxx_I2C ( PinName  sda,
PinName  scl,
char  slave_adr = MB85RC_I2C_ADDRESS 
)

Create an MB85RCxx_I2C instance which is connected to specified I2C pins with specified address.

Parameters:
sdaI2C data line pin
sclI2C clock line pin
slave_adr(option) I2C slave address (default: 0xA0)

Definition at line 32 of file MB85RCxx_I2C.cpp.

~MB85RCxx_I2C (  ) [virtual]

Destructor of MB85RCxx_I2C.

Definition at line 41 of file MB85RCxx_I2C.cpp.


Member Function Documentation

void fill ( uint32_t  address,
uint8_t  data,
uint32_t  length 
)

Fill data to memory address.

Parameters:
addressMemory address
datadata to fill out to memory
lengthNumber of bytes to write

Definition at line 90 of file MB85RCxx_I2C.cpp.

void read ( uint32_t  address,
char *  data,
uint32_t  length 
)

Read data from memory address.

Parameters:
addressMemory address
dataPointer to the byte-array to read data in to
lengthNumber of bytes to read

Definition at line 55 of file MB85RCxx_I2C.cpp.

int read_device_id ( char *  device_id )

Read device ID from MB85RCxx FRAM.

Parameters:
device_idPointer to the byte-array to read data in to
Returns:
memory dencity

Definition at line 47 of file MB85RCxx_I2C.cpp.

void write ( uint32_t  address,
char *  data,
uint32_t  length 
)

Write data to memory address.

Parameters:
addressMemory address
dataPointer to the byte-array data to write
lengthNumber of bytes to write

Definition at line 66 of file MB85RCxx_I2C.cpp.

void write ( uint32_t  address,
char  data 
)

Write data to memory address.

Parameters:
addressMemory address
datadata to write out to memory

Definition at line 79 of file MB85RCxx_I2C.cpp.