upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Data Structures | Functions | Macros | Typedefs
Include dependency graph for mpr121.h:

API Description

//Modified: Abhishek Malik <abhishek.malik@intel.com>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "mpr121.h"
#include "upm_utilities.h"
int main()
{
mpr121_context dev = mpr121_init(MPR121_I2C_BUS, MPR121_DEFAULT_I2C_ADDR);
if(mpr121_config_an3944(dev) != UPM_SUCCESS){
printf("unable to configure device\n");
}
uint32_t states;
while(1){
if(mpr121_read_buttons(dev, &states, 0) != UPM_SUCCESS){
printf("Error while reading button values\n");
}
printf("retrieved button states: %d\n", states);
upm_delay(1);
}
printf("all done!!\n");
return 0;
}

Go to the source code of this file.

Data Structures

struct  _mpr121_context
 

Functions

mpr121_context mpr121_init (int bus, uint8_t address)
 
void mpr121_close (mpr121_context dev)
 
upm_result_t mpr121_config_an3944 (mpr121_context dev)
 
upm_result_t mpr121_read_buttons (mpr121_context dev, uint32_t *states, int num)
 
upm_result_t mpr121_write_bytes (mpr121_context dev, uint8_t reg, uint8_t *buffer, int len)
 
upm_result_t mpr121_read_bytes (mpr121_context dev, uint8_t reg, uint8_t *buffer, int len)
 

Macros

#define MPR121_I2C_BUS   0
 
#define MPR121_DEFAULT_I2C_ADDR   0x5a
 

Typedefs

typedef struct _mpr121_contextmpr121_context
 

Function Documentation

mpr121_context mpr121_init ( int  bus,
uint8_t  address 
)

MPR121 Init function

Parameters
busi2c bus
addressi2c address of the sensor
Returns
void* pointer to the sensor struct
void mpr121_close ( mpr121_context  dev)

MPR121 Close function

Parameters
devpointer to sensor struct
upm_result_t mpr121_config_an3944 ( mpr121_context  dev)

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.

Parameters
devpointer to the sensor struct
Returns
upm_result_t UPM success/error code

Here is the call graph for this function:

upm_result_t mpr121_read_buttons ( mpr121_context  dev,
uint32_t *  states,
int  num 
)

Function to read the individual button values

Parameters
devpointer to the sensor struct
statesPointer to store the states of the individual buttons
numused to retrieve the state of a particular button
Returns
upm_result_t UPM success/error code

Here is the call graph for this function:

upm_result_t mpr121_write_bytes ( mpr121_context  dev,
uint8_t  reg,
uint8_t *  buffer,
int  len 
)

Function used to write multiple bytes to the i2c bus

Parameters
devsensor struct
regi2c register to read from
*bufferpointer that contains the values that have to be written to the registers
lenlength of the values that have to be written to the regs
Returns
upm_result_t UPM success/error code

Here is the caller graph for this function:

upm_result_t mpr121_read_bytes ( mpr121_context  dev,
uint8_t  reg,
uint8_t *  buffer,
int  len 
)

Function used to read multiple bytes from the i2c bus

Parameters
devsensor struct
regi2c register to read from
*bufferpointer that contains the values that have been read from the registers
lenlength of the values that have to be read
Returns
upm_result_t UPM success/error code

Here is the caller graph for this function:

Typedef Documentation

typedef struct _mpr121_context * mpr121_context

device context