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