Dragan Grgić / Mbed 2 deprecated i2c-scanner

Dependencies:   mbed

Fork of i2c scanner by R K

Files at this revision

API Documentation at this revision

Comitter:
Grginho
Date:
Sat Sep 09 10:50:12 2017 +0000
Parent:
0:d58e47b3cc7e
Commit message:
Casey

Changed in this revision

SensorBoards.cpp Show annotated file Show diff for this revision Revisions of this file
SensorBoards.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
test.txt Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SensorBoards.cpp	Sat Sep 09 10:50:12 2017 +0000
@@ -0,0 +1,20 @@
+#include "SensorBoards.h"
+
+uint8_t getSensorNumbers(uint8_t address)
+{
+    //return boards[0].numberOfSensors;
+}
+uint8_t getSensorIDs(uint8_t address, uint8_t *IDBuffer){}
+void getSensorReadings(uint8_t address, uint8_t ID, uint8_t* IDMeasure){}
+int8_t SensorBoardScanner()
+{
+    I2C i2c(D14, D15);        // sda, scl
+    Serial pc(USBTX, USBRX); // tx, rx
+    pc.printf("RUN\r\n");
+    for(int i = 0; i < 128 ; i++) {
+        i2c.start();
+        //Upisi u boards[i]
+        if(i2c.write(i << 1)) pc.printf("0x%x ACK \r\n",i); // Send command string
+        i2c.stop();
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SensorBoards.h	Sat Sep 09 10:50:12 2017 +0000
@@ -0,0 +1,28 @@
+#ifndef _SENSORBOARDS_H
+#define _SENSORBOARDS_H
+#include "mbed.h"
+
+#define SENSOR_NUMBERS 0xA1
+#define SENSORS_IDS 0xA2
+#define SENSOR_READINGS 0xA3
+
+struct Board
+{
+	uint8_t I2CAddress;
+	uint8_t sensorIDs[8];
+	uint8_t numberOfSensors;
+};
+
+class SensorBoards
+{
+public:
+	uint8_t sensorBoardScanner();
+	uint8_t sensorIDScanner();
+	uint8_t getSensorNumbers(uint8_t address);
+	uint8_t getSensorIDs(uint8_t address, uint8_t *IDBuffer);
+	void getSensorReadings(uint8_t address, uint8_t ID, uint8_t* IDMeasure);
+private:
+	Board boards[1];
+};
+
+#endif
\ No newline at end of file
--- a/main.cpp	Tue Jun 28 18:29:49 2016 +0000
+++ b/main.cpp	Sat Sep 09 10:50:12 2017 +0000
@@ -1,13 +1,8 @@
 #include "mbed.h"
-I2C i2c(D14, D15);        // sda, scl
-Serial pc(USBTX, USBRX); // tx, rx
+#include "SensorBoards.h"
+
 
 int main()
 {
-    pc.printf("RUN\r\n");
-    for(int i = 0; i < 128 ; i++) {
-        i2c.start();
-        if(i2c.write(i << 1)) pc.printf("0x%x ACK \r\n",i); // Send command string
-        i2c.stop();
-    }
+    
 }
\ No newline at end of file