Sehoon Shon and Tanvir Iqbal's mbed mini project

Dependencies:   Motordriver TextLCD mbed

Fork of TextLCD_HelloWorld by Simon Ford

Committer:
luckybug38
Date:
Thu Oct 11 20:59:05 2012 +0000
Revision:
3:a59397561c9d
PROJECT3;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
luckybug38 3:a59397561c9d 1 /*
luckybug38 3:a59397561c9d 2 Copyright (c) 2011 Anthony Buckton (abuckton [at] blackink [dot} net {dot} au)
luckybug38 3:a59397561c9d 3
luckybug38 3:a59397561c9d 4
luckybug38 3:a59397561c9d 5 Permission is hereby granted, free of charge, to any person obtaining a copy
luckybug38 3:a59397561c9d 6 of this software and associated documentation files (the "Software"), to deal
luckybug38 3:a59397561c9d 7 in the Software without restriction, including without limitation the rights
luckybug38 3:a59397561c9d 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
luckybug38 3:a59397561c9d 9 copies of the Software, and to permit persons to whom the Software is
luckybug38 3:a59397561c9d 10 furnished to do so, subject to the following conditions:
luckybug38 3:a59397561c9d 11
luckybug38 3:a59397561c9d 12 The above copyright notice and this permission notice shall be included in
luckybug38 3:a59397561c9d 13 all copies or substantial portions of the Software.
luckybug38 3:a59397561c9d 14
luckybug38 3:a59397561c9d 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
luckybug38 3:a59397561c9d 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
luckybug38 3:a59397561c9d 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
luckybug38 3:a59397561c9d 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
luckybug38 3:a59397561c9d 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
luckybug38 3:a59397561c9d 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
luckybug38 3:a59397561c9d 21 THE SOFTWARE.
luckybug38 3:a59397561c9d 22
luckybug38 3:a59397561c9d 23 Parts written by Jim Lindblom of Sparkfun
luckybug38 3:a59397561c9d 24 Ported to mbed by A.Buckton, Feb 2011
luckybug38 3:a59397561c9d 25 */
luckybug38 3:a59397561c9d 26
luckybug38 3:a59397561c9d 27 #ifndef MPR121_H
luckybug38 3:a59397561c9d 28 #define MPR121_H
luckybug38 3:a59397561c9d 29
luckybug38 3:a59397561c9d 30 //using namespace std;
luckybug38 3:a59397561c9d 31
luckybug38 3:a59397561c9d 32 class Mpr121
luckybug38 3:a59397561c9d 33 {
luckybug38 3:a59397561c9d 34
luckybug38 3:a59397561c9d 35 public:
luckybug38 3:a59397561c9d 36 // i2c Addresses, bit-shifted
luckybug38 3:a59397561c9d 37 enum Address { ADD_VSS = 0xb4,// ADD->VSS = 0x5a <-wiring on Sparkfun board
luckybug38 3:a59397561c9d 38 ADD_VDD = 0xb6,// ADD->VDD = 0x5b
luckybug38 3:a59397561c9d 39 ADD_SCL = 0xb8,// ADD->SDA = 0x5c
luckybug38 3:a59397561c9d 40 ADD_SDA = 0xba // ADD->SCL = 0x5d
luckybug38 3:a59397561c9d 41 };
luckybug38 3:a59397561c9d 42
luckybug38 3:a59397561c9d 43 // Real initialiser, takes the i2c address of the device.
luckybug38 3:a59397561c9d 44 Mpr121(I2C *i2c, Address i2cAddress);
luckybug38 3:a59397561c9d 45
luckybug38 3:a59397561c9d 46 bool getProximityMode();
luckybug38 3:a59397561c9d 47
luckybug38 3:a59397561c9d 48 void setProximityMode(bool mode);
luckybug38 3:a59397561c9d 49
luckybug38 3:a59397561c9d 50 int readTouchData();
luckybug38 3:a59397561c9d 51
luckybug38 3:a59397561c9d 52 unsigned char read(int key);
luckybug38 3:a59397561c9d 53
luckybug38 3:a59397561c9d 54 int write(int address, unsigned char value);
luckybug38 3:a59397561c9d 55 int writeMany(int start, unsigned char* dataSet, int length);
luckybug38 3:a59397561c9d 56
luckybug38 3:a59397561c9d 57 void setElectrodeThreshold(int electrodeId, unsigned char touchThreshold, unsigned char releaseThreshold);
luckybug38 3:a59397561c9d 58
luckybug38 3:a59397561c9d 59 protected:
luckybug38 3:a59397561c9d 60 // Configures the MPR with standard settings. This is permitted to be overwritten by sub-classes.
luckybug38 3:a59397561c9d 61 void configureSettings();
luckybug38 3:a59397561c9d 62
luckybug38 3:a59397561c9d 63 private:
luckybug38 3:a59397561c9d 64 // The I2C bus instance.
luckybug38 3:a59397561c9d 65 I2C *i2c;
luckybug38 3:a59397561c9d 66
luckybug38 3:a59397561c9d 67 // i2c address of this mpr121
luckybug38 3:a59397561c9d 68 Address address;
luckybug38 3:a59397561c9d 69 };
luckybug38 3:a59397561c9d 70
luckybug38 3:a59397561c9d 71
luckybug38 3:a59397561c9d 72 // MPR121 Register Defines
luckybug38 3:a59397561c9d 73 #define MHD_R 0x2B
luckybug38 3:a59397561c9d 74 #define NHD_R 0x2C
luckybug38 3:a59397561c9d 75 #define NCL_R 0x2D
luckybug38 3:a59397561c9d 76 #define FDL_R 0x2E
luckybug38 3:a59397561c9d 77 #define MHD_F 0x2F
luckybug38 3:a59397561c9d 78 #define NHD_F 0x30
luckybug38 3:a59397561c9d 79 #define NCL_F 0x31
luckybug38 3:a59397561c9d 80 #define FDL_F 0x32
luckybug38 3:a59397561c9d 81 #define NHDT 0x33
luckybug38 3:a59397561c9d 82 #define NCLT 0x34
luckybug38 3:a59397561c9d 83 #define FDLT 0x35
luckybug38 3:a59397561c9d 84 // Proximity sensing controls
luckybug38 3:a59397561c9d 85 #define MHDPROXR 0x36
luckybug38 3:a59397561c9d 86 #define NHDPROXR 0x37
luckybug38 3:a59397561c9d 87 #define NCLPROXR 0x38
luckybug38 3:a59397561c9d 88 #define FDLPROXR 0x39
luckybug38 3:a59397561c9d 89 #define MHDPROXF 0x3A
luckybug38 3:a59397561c9d 90 #define NHDPROXF 0x3B
luckybug38 3:a59397561c9d 91 #define NCLPROXF 0x3C
luckybug38 3:a59397561c9d 92 #define FDLPROXF 0x3D
luckybug38 3:a59397561c9d 93 #define NHDPROXT 0x3E
luckybug38 3:a59397561c9d 94 #define NCLPROXT 0x3F
luckybug38 3:a59397561c9d 95 #define FDLPROXT 0x40
luckybug38 3:a59397561c9d 96 // Electrode Touch/Release thresholds
luckybug38 3:a59397561c9d 97 #define ELE0_T 0x41
luckybug38 3:a59397561c9d 98 #define ELE0_R 0x42
luckybug38 3:a59397561c9d 99 #define ELE1_T 0x43
luckybug38 3:a59397561c9d 100 #define ELE1_R 0x44
luckybug38 3:a59397561c9d 101 #define ELE2_T 0x45
luckybug38 3:a59397561c9d 102 #define ELE2_R 0x46
luckybug38 3:a59397561c9d 103 #define ELE3_T 0x47
luckybug38 3:a59397561c9d 104 #define ELE3_R 0x48
luckybug38 3:a59397561c9d 105 #define ELE4_T 0x49
luckybug38 3:a59397561c9d 106 #define ELE4_R 0x4A
luckybug38 3:a59397561c9d 107 #define ELE5_T 0x4B
luckybug38 3:a59397561c9d 108 #define ELE5_R 0x4C
luckybug38 3:a59397561c9d 109 #define ELE6_T 0x4D
luckybug38 3:a59397561c9d 110 #define ELE6_R 0x4E
luckybug38 3:a59397561c9d 111 #define ELE7_T 0x4F
luckybug38 3:a59397561c9d 112 #define ELE7_R 0x50
luckybug38 3:a59397561c9d 113 #define ELE8_T 0x51
luckybug38 3:a59397561c9d 114 #define ELE8_R 0x52
luckybug38 3:a59397561c9d 115 #define ELE9_T 0x53
luckybug38 3:a59397561c9d 116 #define ELE9_R 0x54
luckybug38 3:a59397561c9d 117 #define ELE10_T 0x55
luckybug38 3:a59397561c9d 118 #define ELE10_R 0x56
luckybug38 3:a59397561c9d 119 #define ELE11_T 0x57
luckybug38 3:a59397561c9d 120 #define ELE11_R 0x58
luckybug38 3:a59397561c9d 121 // Proximity Touch/Release thresholds
luckybug38 3:a59397561c9d 122 #define EPROXTTH 0x59
luckybug38 3:a59397561c9d 123 #define EPROXRTH 0x5A
luckybug38 3:a59397561c9d 124 // Debounce configuration
luckybug38 3:a59397561c9d 125 #define DEB_CFG 0x5B
luckybug38 3:a59397561c9d 126 // AFE- Analogue Front End configuration
luckybug38 3:a59397561c9d 127 #define AFE_CFG 0x5C
luckybug38 3:a59397561c9d 128 // Filter configuration
luckybug38 3:a59397561c9d 129 #define FIL_CFG 0x5D
luckybug38 3:a59397561c9d 130 // Electrode configuration - transistions to "active mode"
luckybug38 3:a59397561c9d 131 #define ELE_CFG 0x5E
luckybug38 3:a59397561c9d 132
luckybug38 3:a59397561c9d 133 #define GPIO_CTRL0 0x73
luckybug38 3:a59397561c9d 134 #define GPIO_CTRL1 0x74
luckybug38 3:a59397561c9d 135 #define GPIO_DATA 0x75
luckybug38 3:a59397561c9d 136 #define GPIO_DIR 0x76
luckybug38 3:a59397561c9d 137 #define GPIO_EN 0x77
luckybug38 3:a59397561c9d 138 #define GPIO_SET 0x78
luckybug38 3:a59397561c9d 139 #define GPIO_CLEAR 0x79
luckybug38 3:a59397561c9d 140 #define GPIO_TOGGLE 0x7A
luckybug38 3:a59397561c9d 141 // Auto configration registers
luckybug38 3:a59397561c9d 142 #define AUTO_CFG_0 0x7B
luckybug38 3:a59397561c9d 143 #define AUTO_CFG_U 0x7D
luckybug38 3:a59397561c9d 144 #define AUTO_CFG_L 0x7E
luckybug38 3:a59397561c9d 145 #define AUTO_CFG_T 0x7F
luckybug38 3:a59397561c9d 146
luckybug38 3:a59397561c9d 147 // Threshold defaults
luckybug38 3:a59397561c9d 148 // Electrode touch threshold
luckybug38 3:a59397561c9d 149 #define E_THR_T 0x0F
luckybug38 3:a59397561c9d 150 // Electrode release threshold
luckybug38 3:a59397561c9d 151 #define E_THR_R 0x0A
luckybug38 3:a59397561c9d 152 // Prox touch threshold
luckybug38 3:a59397561c9d 153 #define PROX_THR_T 0x02
luckybug38 3:a59397561c9d 154 // Prox release threshold
luckybug38 3:a59397561c9d 155 #define PROX_THR_R 0x02
luckybug38 3:a59397561c9d 156
luckybug38 3:a59397561c9d 157 #endif