Seeed / eMPL_MPU
Embed: (wiki syntax)

« Back to documentation index

MBED System Layer

MBED System Layer

MBED System Layer APIs. More...

Files

file  mbed_i2c.h
 

Serial communication functions needed by eMPL to communicate to the MPU devices.


file  mbed_spi.h
 

Serial communication functions needed by eMPL to communicate to the MPU devices.


Functions

void mbed_i2c_enable (void)
 Set up the I2C port and configure the MBED as the master.
void mbed_i2c_disable (void)
 Disable I2C communication.
int mbed_i2c_write (unsigned char slave_addr, unsigned char reg_addr, unsigned char length, unsigned char const *data)
 Write to a device register.
int mbed_i2c_read (unsigned char slave_addr, unsigned char reg_addr, unsigned char length, unsigned char *data)
 Read from a device.
void mbed_spi_init (PinName mosi, PinName miso, PinName sclk, PinName cs)
 Set up the SPI port and configure the MBED as the master.
void mbed_spi_enable (void)
 Enable SPI port.
void mbed_spi_disable (void)
 Disable SPI communication.
int mbed_spi_write (unsigned char reg_addr, unsigned char length, unsigned char const *data)
 Write to a device register.
int mbed_spi_read (unsigned char reg_addr, unsigned char length, unsigned char *data)
 Read from a device.

Detailed Description

MBED System Layer APIs.

To interface with any platform, eMPL needs access to various system layer functions.


Function Documentation

void mbed_i2c_disable ( void   )

Disable I2C communication.

This function will disable the I2C hardware and should be called prior to entering low-power mode.

Returns:
0 if successful.

Definition at line 111 of file mbed_i2c.c.

void mbed_i2c_enable ( void   )

Set up the I2C port and configure the MBED as the master.

Returns:
0 if successful.

Definition at line 101 of file mbed_i2c.c.

int mbed_i2c_read ( unsigned char  slave_addr,
unsigned char  reg_addr,
unsigned char  length,
unsigned char *  data 
)

Read from a device.

Parameters:
[in]slave_addrSlave address of device.
[in]reg_addrSlave register to be read from.
[in]lengthNumber of bytes to read.
[out]dataData from register.
Returns:
0 if successful.

Definition at line 45 of file mbed_i2c.c.

int mbed_i2c_write ( unsigned char  slave_addr,
unsigned char  reg_addr,
unsigned char  length,
unsigned char const *  data 
)

Write to a device register.

Parameters:
[in]slave_addrSlave address of device.
[in]reg_addrSlave register to be written to.
[in]lengthNumber of bytes to write.
[out]dataData to be written to register.
Returns:
0 if successful.

Definition at line 28 of file mbed_i2c.c.

void mbed_spi_disable ( void   )

Disable SPI communication.

This function will disable the SPI hardware and should be called prior to entering low-power mode.

Definition at line 88 of file mbed_spi.c.

void mbed_spi_enable ( void   )

Enable SPI port.

Definition at line 76 of file mbed_spi.c.

void mbed_spi_init ( PinName  mosi,
PinName  miso,
PinName  sclk,
PinName  cs 
)

Set up the SPI port and configure the MBED as the master.

Definition at line 23 of file mbed_spi.c.

int mbed_spi_read ( unsigned char  reg_addr,
unsigned char  length,
unsigned char *  data 
)

Read from a device.

Parameters:
[in]reg_addrSlave register to be read from.
[in]lengthNumber of bytes to read.
[out]dataData from register.
Returns:
0 if successful.

Definition at line 60 of file mbed_spi.c.

int mbed_spi_write ( unsigned char  reg_addr,
unsigned char  length,
unsigned char const *  data 
)

Write to a device register.

Parameters:
[in]reg_addrSlave register to be written to.
[in]lengthNumber of bytes to write.
[out]dataData to be written to register.
Returns:
0 if successful.

Definition at line 45 of file mbed_spi.c.