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) 反転させることにより、疑似リセットクロックを生成します。
その後は、通常の起動手順に復帰し、以降はこれまでと同様の動作をします。
Diff: sensors/VEML6040.h
- Revision:
- 0:d895cd1cd897
diff -r 000000000000 -r d895cd1cd897 sensors/VEML6040.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sensors/VEML6040.h Tue Apr 03 08:30:29 2018 +0000 @@ -0,0 +1,155 @@ +#ifndef _VEML6040_H_ +#define _VEML6040_H_ + +#include "mbed.h" + +/** + * RGBW Color Sensor with I2C Interface + * I2C 7bit address: 0x10 + * + */ + +class VEML6040 +{ +public: + /** + * constructor + * + * @param i2c Pointer of the I2C object + * @param addr address of the I2C peripheral + */ + VEML6040(I2C *i2c, int addr) ; + + /** + * destructor + */ + ~VEML6040() ; + +/** + * get Red + * @param none + * @returns float value of Red + */ +float getR(void) ; // return float value of Red + +/** + * get Green + * @param none + * @returns float value of Green + */ +float getG(void) ; // return float value of Green + +/** + * get Blue + * @param none + * @returns float value of Blue + */ +float getB(void) ; // return float value of Blue + +/** + * get White + * @param none + * @returns float value of White + */ +float getW(void) ; // return float value of White + +/** + * get CCT(McCAMY FORMULA) value X + * @param none + * @returns float CCT value X + */ +float getX(void) ; // return float value of X + +/** + * get CCT(McCAMY FOMULA) value Y + * @param none + * @returns float CCT value Y + */ +float getY(void) ; // return float value of Y + +/** + * get CCT(McCAMY FOMULA) value Z + * @param none + * @returns float CCT value Z + */ +float getZ(void) ; // return float value of Z + +/** + * get CIE1931 X + * @param none + * @returns float CIE1931 X + */ +float getCIEX(void) ; // return float value of CIE1931_x + +/** + * get CIE1931 Y + * @param none + * @returns float CIE1931 Y + */ +float getCIEY(void) ; // return float value of CIE1931_y + +/** + * get color config data + * @param *colorconf uint8_t + * @reutns 0: success non-0: failure + */ +int getCOLORConf(uint8_t *colorconf) ; + +/** + * set color config data + * @param *colorconf uint8_t + * @returns 0: success non-0: failure + */ +int setCOLORConf(uint8_t colorconf) ; + +/** + * get raw Red data + * @param uint16_t *rdata + * @returns i2c status 0: success non-0: failure + */ +int getRData(uint16_t *rdata) ; + +/** + * get raw Green data + * @param uint16_t *gdata + * @returns i2c status 0: success non-0: failure + */ +int getGData(uint16_t *gdata) ; + +/** + * get raw Blue data + * @param uint16_t *bdata + * @returns i2c status 0: success non-0: failure + */ +int getBData(uint16_t *bdata) ; + +/** + * get raw White data + * @param uint16_t *wdata + * @returns i2c status 0: success non-0: failure + */ +int getWData(uint16_t *wdata) ; + +// void getCCTiData(uint16_t *cctidata) ; +/** + * get CCTi data for CCT (EMPIRICAL APPROACH) + * @param none + * @returns float CCTi data + */ +float getCCTiData(void) ; +// void getCCTData(uint16_t *cctdata) ; + +/** + * get CCT data (EMPIRICAL APPROACH) + * @param none + * @returns float CCD data + */ +float getCCTData(void) ; + +private: + I2C *p_i2c; + int m_addr; + int readRegs(int addr, uint8_t * data, int len); + int writeRegs(uint8_t * data, int len); +} ; +#endif /* _VEML6040_H_ */