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