I2C hang recover function added
Dependencies: UniGraphic mbed vt100
In this version, check_i2c_pins function was added in edge_mgr.cpp.
プログラムの起動時、I2Cモジュールを初期化する前に、I2Cに使用するピンの電位を確認し
もし一方でも Low に張り付いていた場合、SCL を GPIO 出力に設定して
所定回数 (I2C_UNLOCK_TRIAL_CYCLE) 反転させることにより、疑似リセットクロックを生成します。
その後は、通常の起動手順に復帰し、以降はこれまでと同様の動作をします。
sensors/VEML6040.h@2:de22987be9ba, 2018-06-18 (annotated)
- Committer:
- gaku_miyagawa
- Date:
- Mon Jun 18 02:55:38 2018 +0000
- Revision:
- 2:de22987be9ba
- Parent:
- 0:d895cd1cd897
SBU SPECIAL
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Rhyme | 0:d895cd1cd897 | 1 | #ifndef _VEML6040_H_ |
Rhyme | 0:d895cd1cd897 | 2 | #define _VEML6040_H_ |
Rhyme | 0:d895cd1cd897 | 3 | |
Rhyme | 0:d895cd1cd897 | 4 | #include "mbed.h" |
Rhyme | 0:d895cd1cd897 | 5 | |
Rhyme | 0:d895cd1cd897 | 6 | /** |
Rhyme | 0:d895cd1cd897 | 7 | * RGBW Color Sensor with I2C Interface |
Rhyme | 0:d895cd1cd897 | 8 | * I2C 7bit address: 0x10 |
Rhyme | 0:d895cd1cd897 | 9 | * |
Rhyme | 0:d895cd1cd897 | 10 | */ |
Rhyme | 0:d895cd1cd897 | 11 | |
Rhyme | 0:d895cd1cd897 | 12 | class VEML6040 |
Rhyme | 0:d895cd1cd897 | 13 | { |
Rhyme | 0:d895cd1cd897 | 14 | public: |
Rhyme | 0:d895cd1cd897 | 15 | /** |
Rhyme | 0:d895cd1cd897 | 16 | * constructor |
Rhyme | 0:d895cd1cd897 | 17 | * |
Rhyme | 0:d895cd1cd897 | 18 | * @param i2c Pointer of the I2C object |
Rhyme | 0:d895cd1cd897 | 19 | * @param addr address of the I2C peripheral |
Rhyme | 0:d895cd1cd897 | 20 | */ |
Rhyme | 0:d895cd1cd897 | 21 | VEML6040(I2C *i2c, int addr) ; |
Rhyme | 0:d895cd1cd897 | 22 | |
Rhyme | 0:d895cd1cd897 | 23 | /** |
Rhyme | 0:d895cd1cd897 | 24 | * destructor |
Rhyme | 0:d895cd1cd897 | 25 | */ |
Rhyme | 0:d895cd1cd897 | 26 | ~VEML6040() ; |
Rhyme | 0:d895cd1cd897 | 27 | |
Rhyme | 0:d895cd1cd897 | 28 | /** |
Rhyme | 0:d895cd1cd897 | 29 | * get Red |
Rhyme | 0:d895cd1cd897 | 30 | * @param none |
Rhyme | 0:d895cd1cd897 | 31 | * @returns float value of Red |
Rhyme | 0:d895cd1cd897 | 32 | */ |
Rhyme | 0:d895cd1cd897 | 33 | float getR(void) ; // return float value of Red |
Rhyme | 0:d895cd1cd897 | 34 | |
Rhyme | 0:d895cd1cd897 | 35 | /** |
Rhyme | 0:d895cd1cd897 | 36 | * get Green |
Rhyme | 0:d895cd1cd897 | 37 | * @param none |
Rhyme | 0:d895cd1cd897 | 38 | * @returns float value of Green |
Rhyme | 0:d895cd1cd897 | 39 | */ |
Rhyme | 0:d895cd1cd897 | 40 | float getG(void) ; // return float value of Green |
Rhyme | 0:d895cd1cd897 | 41 | |
Rhyme | 0:d895cd1cd897 | 42 | /** |
Rhyme | 0:d895cd1cd897 | 43 | * get Blue |
Rhyme | 0:d895cd1cd897 | 44 | * @param none |
Rhyme | 0:d895cd1cd897 | 45 | * @returns float value of Blue |
Rhyme | 0:d895cd1cd897 | 46 | */ |
Rhyme | 0:d895cd1cd897 | 47 | float getB(void) ; // return float value of Blue |
Rhyme | 0:d895cd1cd897 | 48 | |
Rhyme | 0:d895cd1cd897 | 49 | /** |
Rhyme | 0:d895cd1cd897 | 50 | * get White |
Rhyme | 0:d895cd1cd897 | 51 | * @param none |
Rhyme | 0:d895cd1cd897 | 52 | * @returns float value of White |
Rhyme | 0:d895cd1cd897 | 53 | */ |
Rhyme | 0:d895cd1cd897 | 54 | float getW(void) ; // return float value of White |
Rhyme | 0:d895cd1cd897 | 55 | |
Rhyme | 0:d895cd1cd897 | 56 | /** |
Rhyme | 0:d895cd1cd897 | 57 | * get CCT(McCAMY FORMULA) value X |
Rhyme | 0:d895cd1cd897 | 58 | * @param none |
Rhyme | 0:d895cd1cd897 | 59 | * @returns float CCT value X |
Rhyme | 0:d895cd1cd897 | 60 | */ |
Rhyme | 0:d895cd1cd897 | 61 | float getX(void) ; // return float value of X |
Rhyme | 0:d895cd1cd897 | 62 | |
Rhyme | 0:d895cd1cd897 | 63 | /** |
Rhyme | 0:d895cd1cd897 | 64 | * get CCT(McCAMY FOMULA) value Y |
Rhyme | 0:d895cd1cd897 | 65 | * @param none |
Rhyme | 0:d895cd1cd897 | 66 | * @returns float CCT value Y |
Rhyme | 0:d895cd1cd897 | 67 | */ |
Rhyme | 0:d895cd1cd897 | 68 | float getY(void) ; // return float value of Y |
Rhyme | 0:d895cd1cd897 | 69 | |
Rhyme | 0:d895cd1cd897 | 70 | /** |
Rhyme | 0:d895cd1cd897 | 71 | * get CCT(McCAMY FOMULA) value Z |
Rhyme | 0:d895cd1cd897 | 72 | * @param none |
Rhyme | 0:d895cd1cd897 | 73 | * @returns float CCT value Z |
Rhyme | 0:d895cd1cd897 | 74 | */ |
Rhyme | 0:d895cd1cd897 | 75 | float getZ(void) ; // return float value of Z |
Rhyme | 0:d895cd1cd897 | 76 | |
Rhyme | 0:d895cd1cd897 | 77 | /** |
Rhyme | 0:d895cd1cd897 | 78 | * get CIE1931 X |
Rhyme | 0:d895cd1cd897 | 79 | * @param none |
Rhyme | 0:d895cd1cd897 | 80 | * @returns float CIE1931 X |
Rhyme | 0:d895cd1cd897 | 81 | */ |
Rhyme | 0:d895cd1cd897 | 82 | float getCIEX(void) ; // return float value of CIE1931_x |
Rhyme | 0:d895cd1cd897 | 83 | |
Rhyme | 0:d895cd1cd897 | 84 | /** |
Rhyme | 0:d895cd1cd897 | 85 | * get CIE1931 Y |
Rhyme | 0:d895cd1cd897 | 86 | * @param none |
Rhyme | 0:d895cd1cd897 | 87 | * @returns float CIE1931 Y |
Rhyme | 0:d895cd1cd897 | 88 | */ |
Rhyme | 0:d895cd1cd897 | 89 | float getCIEY(void) ; // return float value of CIE1931_y |
Rhyme | 0:d895cd1cd897 | 90 | |
Rhyme | 0:d895cd1cd897 | 91 | /** |
Rhyme | 0:d895cd1cd897 | 92 | * get color config data |
Rhyme | 0:d895cd1cd897 | 93 | * @param *colorconf uint8_t |
Rhyme | 0:d895cd1cd897 | 94 | * @reutns 0: success non-0: failure |
Rhyme | 0:d895cd1cd897 | 95 | */ |
Rhyme | 0:d895cd1cd897 | 96 | int getCOLORConf(uint8_t *colorconf) ; |
Rhyme | 0:d895cd1cd897 | 97 | |
Rhyme | 0:d895cd1cd897 | 98 | /** |
Rhyme | 0:d895cd1cd897 | 99 | * set color config data |
Rhyme | 0:d895cd1cd897 | 100 | * @param *colorconf uint8_t |
Rhyme | 0:d895cd1cd897 | 101 | * @returns 0: success non-0: failure |
Rhyme | 0:d895cd1cd897 | 102 | */ |
Rhyme | 0:d895cd1cd897 | 103 | int setCOLORConf(uint8_t colorconf) ; |
Rhyme | 0:d895cd1cd897 | 104 | |
Rhyme | 0:d895cd1cd897 | 105 | /** |
Rhyme | 0:d895cd1cd897 | 106 | * get raw Red data |
Rhyme | 0:d895cd1cd897 | 107 | * @param uint16_t *rdata |
Rhyme | 0:d895cd1cd897 | 108 | * @returns i2c status 0: success non-0: failure |
Rhyme | 0:d895cd1cd897 | 109 | */ |
Rhyme | 0:d895cd1cd897 | 110 | int getRData(uint16_t *rdata) ; |
Rhyme | 0:d895cd1cd897 | 111 | |
Rhyme | 0:d895cd1cd897 | 112 | /** |
Rhyme | 0:d895cd1cd897 | 113 | * get raw Green data |
Rhyme | 0:d895cd1cd897 | 114 | * @param uint16_t *gdata |
Rhyme | 0:d895cd1cd897 | 115 | * @returns i2c status 0: success non-0: failure |
Rhyme | 0:d895cd1cd897 | 116 | */ |
Rhyme | 0:d895cd1cd897 | 117 | int getGData(uint16_t *gdata) ; |
Rhyme | 0:d895cd1cd897 | 118 | |
Rhyme | 0:d895cd1cd897 | 119 | /** |
Rhyme | 0:d895cd1cd897 | 120 | * get raw Blue data |
Rhyme | 0:d895cd1cd897 | 121 | * @param uint16_t *bdata |
Rhyme | 0:d895cd1cd897 | 122 | * @returns i2c status 0: success non-0: failure |
Rhyme | 0:d895cd1cd897 | 123 | */ |
Rhyme | 0:d895cd1cd897 | 124 | int getBData(uint16_t *bdata) ; |
Rhyme | 0:d895cd1cd897 | 125 | |
Rhyme | 0:d895cd1cd897 | 126 | /** |
Rhyme | 0:d895cd1cd897 | 127 | * get raw White data |
Rhyme | 0:d895cd1cd897 | 128 | * @param uint16_t *wdata |
Rhyme | 0:d895cd1cd897 | 129 | * @returns i2c status 0: success non-0: failure |
Rhyme | 0:d895cd1cd897 | 130 | */ |
Rhyme | 0:d895cd1cd897 | 131 | int getWData(uint16_t *wdata) ; |
Rhyme | 0:d895cd1cd897 | 132 | |
Rhyme | 0:d895cd1cd897 | 133 | // void getCCTiData(uint16_t *cctidata) ; |
Rhyme | 0:d895cd1cd897 | 134 | /** |
Rhyme | 0:d895cd1cd897 | 135 | * get CCTi data for CCT (EMPIRICAL APPROACH) |
Rhyme | 0:d895cd1cd897 | 136 | * @param none |
Rhyme | 0:d895cd1cd897 | 137 | * @returns float CCTi data |
Rhyme | 0:d895cd1cd897 | 138 | */ |
Rhyme | 0:d895cd1cd897 | 139 | float getCCTiData(void) ; |
Rhyme | 0:d895cd1cd897 | 140 | // void getCCTData(uint16_t *cctdata) ; |
Rhyme | 0:d895cd1cd897 | 141 | |
Rhyme | 0:d895cd1cd897 | 142 | /** |
Rhyme | 0:d895cd1cd897 | 143 | * get CCT data (EMPIRICAL APPROACH) |
Rhyme | 0:d895cd1cd897 | 144 | * @param none |
Rhyme | 0:d895cd1cd897 | 145 | * @returns float CCD data |
Rhyme | 0:d895cd1cd897 | 146 | */ |
Rhyme | 0:d895cd1cd897 | 147 | float getCCTData(void) ; |
Rhyme | 0:d895cd1cd897 | 148 | |
Rhyme | 0:d895cd1cd897 | 149 | private: |
Rhyme | 0:d895cd1cd897 | 150 | I2C *p_i2c; |
Rhyme | 0:d895cd1cd897 | 151 | int m_addr; |
Rhyme | 0:d895cd1cd897 | 152 | int readRegs(int addr, uint8_t * data, int len); |
Rhyme | 0:d895cd1cd897 | 153 | int writeRegs(uint8_t * data, int len); |
Rhyme | 0:d895cd1cd897 | 154 | } ; |
Rhyme | 0:d895cd1cd897 | 155 | #endif /* _VEML6040_H_ */ |