Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
 All Classes Files Functions Variables Typedefs Macros Groups
I2C_MPR121.h
1 /*
2  * MPR121 Bela demo
3  *
4  * Andrew McPherson
5  * Based on Adafruit library by Limor Fried/Ladyada
6  */
7 
8 #ifndef I2CTK_H_
9 #define I2CTK_H_
10 
11 #include <I2c.h>
12 #include "Utilities.h"
13 
14 typedef bool boolean;
15 
16 #define MPR121_I2CADDR_DEFAULT 0x5A
17 
18 #define MPR121_TOUCHSTATUS_L 0x00
19 #define MPR121_TOUCHSTATUS_H 0x01
20 #define MPR121_FILTDATA_0L 0x04
21 #define MPR121_FILTDATA_0H 0x05
22 #define MPR121_BASELINE_0 0x1E
23 #define MPR121_MHDR 0x2B
24 #define MPR121_NHDR 0x2C
25 #define MPR121_NCLR 0x2D
26 #define MPR121_FDLR 0x2E
27 #define MPR121_MHDF 0x2F
28 #define MPR121_NHDF 0x30
29 #define MPR121_NCLF 0x31
30 #define MPR121_FDLF 0x32
31 #define MPR121_NHDT 0x33
32 #define MPR121_NCLT 0x34
33 #define MPR121_FDLT 0x35
34 
35 #define MPR121_TOUCHTH_0 0x41
36 #define MPR121_RELEASETH_0 0x42
37 #define MPR121_DEBOUNCE 0x5B
38 #define MPR121_CONFIG1 0x5C
39 #define MPR121_CONFIG2 0x5D
40 #define MPR121_CHARGECURR_0 0x5F
41 #define MPR121_CHARGETIME_1 0x6C
42 #define MPR121_ECR 0x5E
43 #define MPR121_AUTOCONFIG0 0x7B
44 #define MPR121_AUTOCONFIG1 0x7C
45 #define MPR121_UPLIMIT 0x7D
46 #define MPR121_LOWLIMIT 0x7E
47 #define MPR121_TARGETLIMIT 0x7F
48 
49 #define MPR121_GPIODIR 0x76
50 #define MPR121_GPIOEN 0x77
51 #define MPR121_GPIOSET 0x78
52 #define MPR121_GPIOCLR 0x79
53 #define MPR121_GPIOTOGGLE 0x7A
54 
55 #define MPR121_SOFTRESET 0x80
56 
57 class I2C_MPR121 : public I2c
58 {
59 public:
60  // Hardware I2C
61  I2C_MPR121();
62 
63  boolean begin(uint8_t bus = 1, uint8_t i2caddr = MPR121_I2CADDR_DEFAULT);
64 
65  uint16_t filteredData(uint8_t t);
66  uint16_t baselineData(uint8_t t);
67 
68  uint8_t readRegister8(uint8_t reg);
69  uint16_t readRegister16(uint8_t reg);
70  void writeRegister(uint8_t reg, uint8_t value);
71  uint16_t touched(void);
72 
73  void setThresholds(uint8_t touch, uint8_t release);
74 
75  int readI2C() { return 0; } // Unused
76 
77 private:
78  int _i2c_address;
79 };
80 
81 
82 #endif /* I2CTK_H_ */
void writeRegister(uint8_t reg, uint8_t value)
Writes 8-bits to the specified destination register.
Definition: I2C_MPR121.cpp:167
Definition: I2c.h:36
Wiring-inspired utility functions and macros.
Definition: I2C_MPR121.h:57