Macros | Functions
SensorI2C.h File Reference

Detailed Description

Interface to the TI-RTOS I2C driver.

Simplified access to the I2C driver and switching between the two I2C buses.

Driver include

This header file should be included in an application as follows:

#include "stdbool.h"

Go to the source code of this file.

Macros

#define SENSOR_I2C_0   0
 
#define SENSOR_I2C_1   1
 
#define SENSOR_I2C_NONE   -1
 

Functions

bool SensorI2C_open (void)
 Initialize the RTOS I2C driver (must be called only once) More...
 
bool SensorI2C_select (uint8_t i2cInterface, uint8_t i2cAddr)
 Select an I2C interface and I2C device. More...
 
bool SensorI2C_readReg (uint8_t regAddr, uint8_t *pData, uint8_t nBytes)
 Read from an I2C device starting at regAddr. More...
 
bool SensorI2C_writeReg (uint8_t regAddr, uint8_t *pData, uint8_t nBytes)
 Write to an I2C device starting at regAddr. More...
 
bool SensorI2C_read (uint8_t *pData, uint8_t nBytes)
 Burst read from an I2C device. More...
 
bool SensorI2C_write (uint8_t *pData, uint8_t nBytes)
 Burst write to an I2C device. More...
 
void SensorI2C_deselect (void)
 Allow other tasks to access the I2C driver. More...
 
void SensorI2C_close (void)
 Close the I2C interface and release the data lines. More...
 

Macro Definition Documentation

§ SENSOR_I2C_0

#define SENSOR_I2C_0   0

I2C interface 0: humidity, temperature, pressure, light, humidity

§ SENSOR_I2C_1

#define SENSOR_I2C_1   1

I2C interface 1: movement sensor

§ SENSOR_I2C_NONE

#define SENSOR_I2C_NONE   -1

I2C interface not selected

Function Documentation

§ SensorI2C_open()

bool SensorI2C_open ( void  )

Initialize the RTOS I2C driver (must be called only once)

Returns
true if I2C_open succeeds

§ SensorI2C_select()

bool SensorI2C_select ( uint8_t  i2cInterface,
uint8_t  i2cAddr 
)

Select an I2C interface and I2C device.

Parameters
i2cInterface- selected interface (1 for MPU9250, 0 for other sensors)
i2cAddr- I2C slave address of device
Returns
true if success

§ SensorI2C_readReg()

bool SensorI2C_readReg ( uint8_t  regAddr,
uint8_t *  pData,
uint8_t  nBytes 
)

Read from an I2C device starting at regAddr.

Parameters
regAddr- which register to read
pData- pointer to data buffer
nBytes- number of bytes to read
Returns
true if the required number of bytes are received
Precondition
A sensor must be selected before this routine is called.

§ SensorI2C_writeReg()

bool SensorI2C_writeReg ( uint8_t  regAddr,
uint8_t *  pData,
uint8_t  nBytes 
)

Write to an I2C device starting at regAddr.

Parameters
regAddr- which register to write
pData- pointer to data buffer
nBytes- number of bytes to write
Returns
true if successful write
Precondition
A sensor must be selected before this routine is called.

§ SensorI2C_read()

bool SensorI2C_read ( uint8_t *  pData,
uint8_t  nBytes 
)

Burst read from an I2C device.

Parameters
pData- pointer to data buffer
nBytes- number of bytes to write
Returns
true if success
Precondition
A sensor and register must be selected before this routine is called.

§ SensorI2C_write()

bool SensorI2C_write ( uint8_t *  pData,
uint8_t  nBytes 
)

Burst write to an I2C device.

Parameters
pData- pointer to data buffer
nBytes- number of bytes to write
Returns
true if success
Precondition
A sensor and register must be selected before this routine is called.

§ SensorI2C_deselect()

void SensorI2C_deselect ( void  )

Allow other tasks to access the I2C driver.

§ SensorI2C_close()

void SensorI2C_close ( void  )

Close the I2C interface and release the data lines.

Returns
true if I2C_open succeeds
Copyright 2018, Texas Instruments Incorporated