library to access typical i2c device
Diff: i2c_general_io.h
- Revision:
- 0:712b59c07bd3
- Child:
- 1:e7e87f75c0d5
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/i2c_general_io.h Tue Jul 03 10:14:45 2018 +0000 @@ -0,0 +1,42 @@ +/* +Copyright (c) 2018 @j_rocket_boy(Twitter) + +典型的なi2c接続のセンサの設定をしたり値を読むためのライブラリ +このライブラリはMITライセンスです. + +This is a library for accessing registers of a typical i2c sensor to set or read +measurement value. +This library is released under the MIT License. + +About MIT license +https://opensource.org/licenses/mit-license.php +*/ + +#ifndef INCLUDED_i2c_genela_io_h_ +#define INCLUDED_i2c_genela_io_h_ +#include "mbed.h" + +class GEN_I2C{ + + public: + + GEN_I2C(PinName sda, PinName sck); + GEN_I2C(I2C &i2c_obj); + + virtual ~GEN_I2C(); + + + //multi bytes func + int read_reg(char Device_add, char reg_add, char *data, int n); + + //single byte func + char read_reg(char Device_add, char reg_add); + int write_reg(char Device_add, char reg_add, char data); + + private: + I2C *i2c_p; + I2C &i2c; + +}; + +#endif \ No newline at end of file