Permalink
Browse files

Made source files compile again, needs testing for multi master

  • Loading branch information...
1 parent 07de667 commit dcb37cb4ede10a77bf861d034cd888bd83817793 @henkmuller henkmuller committed Dec 12, 2011
Showing with 16 additions and 18 deletions.
  1. +11 −10 doc/summary.rst
  2. +5 −8 module_i2c_master/src/i2c-mm.xc
View
@@ -37,16 +37,17 @@ when required.
module_i2c_master
-----------------
-This module will support single master, at 100 or 400 kb/s with clock
-stretching on multiple I2C busses. It will provide the same interface as module_i2c_simple.
-
-+---------------------------+-----------------------+------------------------+
-| Functionality provided | Resources required | Status |
-| +-----------+-----------+ |
-| | ports | Memory | |
-+---------------------------+-----------+-----------+------------------------+
-| Multi master | 2 |600+? bytes| To be implemented |
-+---------------------------+-----------+-----------+------------------------+
+This module will support must master, at 100 or 400 kb/s with clock
+stretching on multiple I2C busses. It provides virtually the same interface as
+module_i2c_simple.
+
++---------------------------+------------------------+------------------------+
+| Functionality provided | Resources required | Status |
+| +-----------+------------+ |
+| | ports | Memory | |
++---------------------------+-----------+------------+------------------------+
+| Multi master | 2 | 800? bytes | To be implemented |
++---------------------------+-----------+------------+------------------------+
The interface comprises three functions, init, rx, and tx that are called
when required.
@@ -45,13 +45,14 @@ static int highPulse(struct r_i2c &i2c, int doSample) {
return temp;
}
-static void startBit(struct r_i2c &i2c, int waitFor) {
- if (wait) {
+static void startBit(struct r_i2c &i2c, int waitForQuiet) {
+ if (waitForQuiet) {
timer t;
- t :> time;
+ int time;
int done = 0;
int sdaState = 1;
int sclState = 1;
+ t :> time;
while(!done) {
select {
case i2c.sda when pinsneq(sdaState) :> sdaState:
@@ -60,7 +61,7 @@ static void startBit(struct r_i2c &i2c, int waitFor) {
case i2c.scl when pinsneq(sclState) :> sclState:
t :> time;
break;
- sdaState && sclState => case t when timerafter(t+I2C_BIT_TIME) :> void:
+ case sdaState && sclState => t when timerafter(time+i2c.clockTicks) :> void:
done = 1;
break;
}
@@ -102,7 +103,6 @@ static int tx8(struct r_i2c &i2c, unsigned data) {
highPulse(i2c, 0);
}
CtlAdrsData >>= 1;
- if (i2c.sda
}
return highPulse(i2c, 1);
}
@@ -131,9 +131,6 @@ static int i2c_master_do_rx(int device, unsigned char data[], int nbytes, struct
}
int i2c_master_rx(int device, unsigned char data[], int nbytes, struct r_i2c &i2c) {
- int i;
- int rdData = 0;
-
startBit(i2c, 1);
return i2c_master_do_rx(device, data, nbytes, i2c);
}

0 comments on commit dcb37cb

Please sign in to comment.