Xbee-Smart-Home-Inside RX Test

Dependencies:   Si7021 mbed-rtos JPEGCamera mbed

Fork of Xbee-Smart-Home-Inside by prana koirala

Committer:
pkoirala3
Date:
Tue May 02 21:41:59 2017 +0000
Revision:
7:fdfe30cea3c2
Parent:
3:415ccd1f7ae1
Final Version

Who changed what in which revision?

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