Mbed_Text_Reader using an SDcard reader, 12-key touch pad and uLCD.

Dependencies:   FATFileSystem mbed-rtos mbed

Committer:
ndureja3
Date:
Mon Mar 24 06:48:12 2014 +0000
Revision:
1:806d2fa3e155
Parent:
0:6bd0fe190ecc
24 Mar 2014

Who changed what in which revision?

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