IS31SE5000 IR SENSOR FOR TOUCHLESS MOTION AND PROXIMITY

Dependents:   test_IS31SE5000 testSensor

Committer:
Rhyme
Date:
Thu May 11 07:26:49 2017 +0000
Revision:
1:3f4ccc809dfc
Parent:
0:b92d4b745118
Child:
2:215d002d2bbf
Comments added

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rhyme 0:b92d4b745118 1 /**
Rhyme 0:b92d4b745118 2 * IR31SE5000 : IR sensor for touchless motion and proximity
Rhyme 0:b92d4b745118 3 * IS31SE5000.h
Rhyme 0:b92d4b745118 4 *
Rhyme 0:b92d4b745118 5 */
Rhyme 0:b92d4b745118 6
Rhyme 0:b92d4b745118 7 #ifndef _IS31SE5000_h_
Rhyme 0:b92d4b745118 8 #define _IS31SE5000_h_
Rhyme 0:b92d4b745118 9
Rhyme 0:b92d4b745118 10 class IS31SE5000
Rhyme 0:b92d4b745118 11 {
Rhyme 0:b92d4b745118 12 public:
Rhyme 0:b92d4b745118 13 /**
Rhyme 0:b92d4b745118 14 * constructor
Rhyme 0:b92d4b745118 15 *
Rhyme 0:b92d4b745118 16 * @param sda SDA pin
Rhyme 0:b92d4b745118 17 * @param scl SCL pin
Rhyme 0:b92d4b745118 18 * @param addr 7bit address of the I2C peripheral
Rhyme 0:b92d4b745118 19 */
Rhyme 0:b92d4b745118 20 IS31SE5000(PinName sda, PinName scl, int addr) ;
Rhyme 0:b92d4b745118 21
Rhyme 0:b92d4b745118 22 ~IS31SE5000() ;
Rhyme 0:b92d4b745118 23
Rhyme 1:3f4ccc809dfc 24 /**
Rhyme 1:3f4ccc809dfc 25 * get status register value
Rhyme 1:3f4ccc809dfc 26 *
Rhyme 1:3f4ccc809dfc 27 * @param none
Rhyme 1:3f4ccc809dfc 28 * @returns uint8_t status register value
Rhyme 1:3f4ccc809dfc 29 *
Rhyme 1:3f4ccc809dfc 30 * @note status register 0x00
Rhyme 1:3f4ccc809dfc 31 * @note bit[7:4] (reserved)
Rhyme 1:3f4ccc809dfc 32 * @note -
Rhyme 1:3f4ccc809dfc 33 * @note bit[3:2] PD
Rhyme 1:3f4ccc809dfc 34 * @note 01: Be off, 02: Be close, Others: No motion
Rhyme 1:3f4ccc809dfc 35 * @note -
Rhyme 1:3f4ccc809dfc 36 * @note bit[1:0] MD
Rhyme 1:3f4ccc809dfc 37 * @note 01: From PD2 to PD1, 10: From PD1 to PD2, Others: No motion
Rhyme 1:3f4ccc809dfc 38 */
Rhyme 1:3f4ccc809dfc 39 uint8_t getStatus(void) ;
Rhyme 1:3f4ccc809dfc 40
Rhyme 1:3f4ccc809dfc 41 /**
Rhyme 1:3f4ccc809dfc 42 * get Proximity Detection Value
Rhyme 1:3f4ccc809dfc 43 *
Rhyme 1:3f4ccc809dfc 44 * @param none
Rhyme 1:3f4ccc809dfc 45 * @returns uint8_t value of PD part of status register bit[3:2]
Rhyme 1:3f4ccc809dfc 46 */
Rhyme 1:3f4ccc809dfc 47 uint8_t getPD(void) ;
Rhyme 0:b92d4b745118 48
Rhyme 1:3f4ccc809dfc 49 /**
Rhyme 1:3f4ccc809dfc 50 * get Mortion Detection Value
Rhyme 1:3f4ccc809dfc 51 * @param none
Rhyme 1:3f4ccc809dfc 52 * @returns uint8_t value of MD part of status register bit[1:0]
Rhyme 1:3f4ccc809dfc 53 */
Rhyme 1:3f4ccc809dfc 54 uint8_t getMD(void) ;
Rhyme 1:3f4ccc809dfc 55
Rhyme 1:3f4ccc809dfc 56 /**
Rhyme 1:3f4ccc809dfc 57 * get shutdown register value
Rhyme 1:3f4ccc809dfc 58 *
Rhyme 1:3f4ccc809dfc 59 * @param none
Rhyme 1:3f4ccc809dfc 60 * @returns uint8_t shutdown register value
Rhyme 1:3f4ccc809dfc 61 *
Rhyme 1:3f4ccc809dfc 62 * @note shutdown register (0x01)
Rhyme 1:3f4ccc809dfc 63 * @note bit[7:1] (reserved)
Rhyme 1:3f4ccc809dfc 64 * @note bit[0] SSD
Rhyme 1:3f4ccc809dfc 65 * @note 0: Software shutdown mode, 1: Normal operation
Rhyme 1:3f4ccc809dfc 66 */
Rhyme 1:3f4ccc809dfc 67 uint8_t get_shutdown_reg(void) ;
Rhyme 1:3f4ccc809dfc 68
Rhyme 1:3f4ccc809dfc 69 /**
Rhyme 1:3f4ccc809dfc 70 * activate the device
Rhyme 1:3f4ccc809dfc 71 *
Rhyme 1:3f4ccc809dfc 72 * @param none
Rhyme 1:3f4ccc809dfc 73 * @returns none
Rhyme 1:3f4ccc809dfc 74 */
Rhyme 0:b92d4b745118 75 void activate(void) ;
Rhyme 1:3f4ccc809dfc 76
Rhyme 1:3f4ccc809dfc 77 /**
Rhyme 1:3f4ccc809dfc 78 * (Software) shutdown the device
Rhyme 1:3f4ccc809dfc 79 *
Rhyme 1:3f4ccc809dfc 80 * @param none
Rhyme 1:3f4ccc809dfc 81 * @returns none
Rhyme 1:3f4ccc809dfc 82 */
Rhyme 0:b92d4b745118 83 void shutdown(void) ;
Rhyme 0:b92d4b745118 84
Rhyme 1:3f4ccc809dfc 85 /**
Rhyme 1:3f4ccc809dfc 86 * get Configuration Register value
Rhyme 1:3f4ccc809dfc 87 *
Rhyme 1:3f4ccc809dfc 88 * @param none
Rhyme 1:3f4ccc809dfc 89 * @returns uint8_t configuration register value
Rhyme 1:3f4ccc809dfc 90 *
Rhyme 1:3f4ccc809dfc 91 * @note Configuration Register (0x11)
Rhyme 1:3f4ccc809dfc 92 * @note bit[7:4] (reserved)
Rhyme 1:3f4ccc809dfc 93 * @note -
Rhyme 1:3f4ccc809dfc 94 * @note bit[3:1] EC Emitting Current Setting
Rhyme 1:3f4ccc809dfc 95 * @note 000: 400mA, 001: 280mA, 01x: 210mA, 1xx: 70mA
Rhyme 1:3f4ccc809dfc 96 * @note -
Rhyme 1:3f4ccc809dfc 97 * @note bit[0] MODE Mode Selection
Rhyme 1:3f4ccc809dfc 98 * @note 0: Motion mode, 1: Proximity mode
Rhyme 1:3f4ccc809dfc 99 */
Rhyme 1:3f4ccc809dfc 100 uint8_t get_config_reg(void) ;
Rhyme 1:3f4ccc809dfc 101
Rhyme 1:3f4ccc809dfc 102 /**
Rhyme 1:3f4ccc809dfc 103 * get EC value of Configuration Register bit[3:1]
Rhyme 1:3f4ccc809dfc 104 *
Rhyme 1:3f4ccc809dfc 105 * @param none
Rhyme 1:3f4ccc809dfc 106 * @returns uint8_t EC part of Configuration Register bit[3:1]
Rhyme 1:3f4ccc809dfc 107 */
Rhyme 1:3f4ccc809dfc 108 uint8_t getEC(void) ;
Rhyme 1:3f4ccc809dfc 109
Rhyme 1:3f4ccc809dfc 110 /**
Rhyme 1:3f4ccc809dfc 111 * set EC value to Configuration Register [3:1]
Rhyme 1:3f4ccc809dfc 112 *
Rhyme 1:3f4ccc809dfc 113 * @param uint8_t EC Value to assign, 000b ~ 1xxb
Rhyme 1:3f4ccc809dfc 114 * @returns none
Rhyme 1:3f4ccc809dfc 115 */
Rhyme 1:3f4ccc809dfc 116 void setEC(uint8_t ec_value) ;
Rhyme 0:b92d4b745118 117
Rhyme 1:3f4ccc809dfc 118 /**
Rhyme 1:3f4ccc809dfc 119 * get MODE value of Configuration Register bit[0]
Rhyme 1:3f4ccc809dfc 120 *
Rhyme 1:3f4ccc809dfc 121 * @param none
Rhyme 1:3f4ccc809dfc 122 * @returns uint8_t MODE value of configuration Register bit[0]
Rhyme 1:3f4ccc809dfc 123 */
Rhyme 1:3f4ccc809dfc 124 uint8_t getMode(void) ;
Rhyme 1:3f4ccc809dfc 125
Rhyme 1:3f4ccc809dfc 126 /**
Rhyme 1:3f4ccc809dfc 127 * Set device mode to motion detection
Rhyme 1:3f4ccc809dfc 128 *
Rhyme 1:3f4ccc809dfc 129 * @param none
Rhyme 1:3f4ccc809dfc 130 * @returns none
Rhyme 1:3f4ccc809dfc 131 */
Rhyme 1:3f4ccc809dfc 132 void motionMode(void) ;
Rhyme 1:3f4ccc809dfc 133
Rhyme 1:3f4ccc809dfc 134 /**
Rhyme 1:3f4ccc809dfc 135 * Set device mode to proximity detection
Rhyme 1:3f4ccc809dfc 136 *
Rhyme 1:3f4ccc809dfc 137 * @param none
Rhyme 1:3f4ccc809dfc 138 * @returns none
Rhyme 1:3f4ccc809dfc 139 */
Rhyme 1:3f4ccc809dfc 140 void proximityMode(void) ;
Rhyme 0:b92d4b745118 141
Rhyme 0:b92d4b745118 142 private:
Rhyme 0:b92d4b745118 143 I2C m_i2c;
Rhyme 0:b92d4b745118 144 int m_addr;
Rhyme 0:b92d4b745118 145 void readRegs(int addr, uint8_t *data, int len) ;
Rhyme 0:b92d4b745118 146 void writeRegs(uint8_t *data, int len) ;
Rhyme 0:b92d4b745118 147
Rhyme 0:b92d4b745118 148 uint8_t shutdown_reg ;
Rhyme 0:b92d4b745118 149 uint8_t config_reg ;
Rhyme 0:b92d4b745118 150 } ;
Rhyme 0:b92d4b745118 151
Rhyme 0:b92d4b745118 152 #endif /* _IS31SE5000_h_ */