hidaka sato / i2cmaster

Dependents:   2016_mother_3 WRS2019_master WRS2020_mecanum_node WRS2021_mecanum_driver

Files at this revision

API Documentation at this revision

Comitter:
sgrsn
Date:
Sat Apr 16 04:23:13 2016 +0000
Child:
1:f5811e90881f
Child:
2:890301330892
Commit message:
I2C_Master class

Changed in this revision

i2cmaster.cpp Show annotated file Show diff for this revision Revisions of this file
i2cmaster.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/i2cmaster.cpp	Sat Apr 16 04:23:13 2016 +0000
@@ -0,0 +1,15 @@
+#include "i2cmaster.h"
+
+
+i2c::i2c(PinName p1,PinName p2) : I2C(p1,p2)
+{
+    frequency(400000);
+}
+bool i2c::put(char addr,char reg, char data ,int size)
+{
+    char Data[2] = {data,0};
+    char DATA[2] = {reg,size};
+    bool N = I2C::write(addr,DATA,2);
+    N|= I2C::write(addr,Data,size);
+    return N;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/i2cmaster.h	Sat Apr 16 04:23:13 2016 +0000
@@ -0,0 +1,14 @@
+#ifndef MBED_I2CMASTER_H
+#define MBED_I2CMASTER_H
+
+#include "mbed.h"
+
+class i2c : public I2C//,DigitalOut
+{
+    public:
+    i2c(PinName p1,PinName p2);
+   
+    bool put(char addr,char reg, char data ,int size);
+};
+
+#endif
\ No newline at end of file