upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Public Member Functions | Data Fields

API for the MPR121 I2C Touch Sensor. More...

Detailed Description

UPM module for the MPR121 touch sensor

mpr121.jpg
// Instantiate an MPR121 on I2C bus 0
upm::MPR121 touch(MPR121_I2C_BUS, MPR121_DEFAULT_I2C_ADDR);
// init according to AN3944 defaults
touch.configAN3944();
while (shouldRun) {
touch.readButtons();
printButtons(touch);
upm_delay(1);
}

Public Member Functions

 MPR121 (int bus, uint8_t address=MPR121_DEFAULT_I2C_ADDR)
 
bool configAN3944 ()
 
void readButtons ()
 
mraa::Result writeBytes (uint8_t reg, uint8_t *buffer, int len)
 
int readBytes (uint8_t reg, uint8_t *buffer, int len)
 

Data Fields

uint16_t m_buttonStates
 
bool m_overCurrentFault
 

Constructor & Destructor Documentation

MPR121 ( int  bus,
uint8_t  address = MPR121_DEFAULT_I2C_ADDR 
)

MPR121 constructor

Parameters
busI2C bus to use

Member Function Documentation

bool configAN3944 ( )

MPR121 destructor ~MPR121(); there is no need for the destructor Sets up a default configuration, based on Application Note 3944 (AN3944): http://cache.freescale.com/files/sensors/doc/app_note/AN3944.pdf

After configuration, the sensor is left in the run state.

Returns
True if configuration is successful

Here is the call graph for this function:

void readButtons ( )

Reads button states in the m_buttonStates member variable. Also, sets the m_overCurrentFault variable if overcurrent is detected.

Here is the call graph for this function:

mraa::Result writeBytes ( uint8_t  reg,
uint8_t *  buffer,
int  len 
)

Writes value(s) into registers

Parameters
regRegister location to start writing into
bufferBuffer for data storage
lenNumber of bytes to write
Returns
mraa::Result

Here is the caller graph for this function:

int readBytes ( uint8_t  reg,
uint8_t *  buffer,
int  len 
)

Reads value(s) from registers

Parameters
regRegister location to start reading from
bufferBuffer for data storage
lenNumber of bytes to read

Here is the caller graph for this function:

Field Documentation

uint16_t m_buttonStates

Button states

bool m_overCurrentFault

Overcurrent detected


The documentation for this class was generated from the following files: