Bank Account Security System

Dependencies:   FatFileSystemSD mbed

Committer:
Dhruv_Varun
Date:
Thu Oct 11 20:49:25 2012 +0000
Revision:
0:7e4786a3584b
Code For Bank Account Security System

Who changed what in which revision?

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