LIBRARY FOR HANDLING THE I2C COMMUNICATION

Files at this revision

API Documentation at this revision

Comitter:
caltadaniel
Date:
Thu Feb 09 21:46:39 2017 +0000
Commit message:
FIRST CREATION;

Changed in this revision

motorDriver.cpp Show annotated file Show diff for this revision Revisions of this file
motorDriver.h Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r f890a2a23d44 motorDriver.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/motorDriver.cpp	Thu Feb 09 21:46:39 2017 +0000
@@ -0,0 +1,21 @@
+#include "mbed.h"
+#include "motorDriver.h"
+
+motorDriver::motorDriver(char slaveAddress){
+    this._i2cAddr = slaveAddress;    
+}
+
+int motorDriver::actualPosition(){
+    return 3;
+}
+
+void motorDriver::requestData(char addr, char requestedData ,char *buff, int size){
+    
+}
+
+char motorDriver::addressConverter(char sevenBitAddress){
+    return sevenBitAddress << 1;
+} 
+int motorDriver::charArrayToInt(char *array, int size){
+    return 5;
+}
\ No newline at end of file
diff -r 000000000000 -r f890a2a23d44 motorDriver.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/motorDriver.h	Thu Feb 09 21:46:39 2017 +0000
@@ -0,0 +1,17 @@
+#ifndef MBED_MOTORDRIVER_H
+#define MBED_MOTORDRIVER_H
+#include "mbed.h"
+#define REQUESTPOSITIONADDR 0x40
+#define READBUFFSIZE 3 //reading buffer size
+
+class motorDriver{
+public:
+    motorDriver(char slaveAddress);
+    int actualPosition();
+private:
+    char addressConverter(char sevenBitAddress); 
+    int charArrayToInt(char *array, int size);  
+    void requestData(char addr, char requestedData ,char *buff, int size);
+    char _i2cAddr;  
+    char _readBuffer[READBUFFSIZE];
+}
\ No newline at end of file