summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
5c0f1af)
- timing cleanup
- release bus after transactions so other masters may take the bus
git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@1518
12e2690d-a6be-4b82-a7b7-
67c4a43b65c8
//#warning "Using internal resistors. Won't work on 161x devices."
//#warning "Using internal resistors. Won't work on 161x devices."
-//! Inits bitbanging port, must be called before using the functions below
-void I2C_Init()
+// Take control of the bus
+void I2C_Take()
-
- //Clear SDA and SCL.
- //Direction, not value, is used to set the value.
-
- SCLOUTPUT;
- SDAOUTPUT;
-
I2C_CLOCK_HI();
I2C_DATA_HI();
I2C_CLOCK_HI();
I2C_DATA_HI();
+ SCLOUTPUT;
+ SDAOUTPUT;
+}
+void I2C_Release()
+{
+ SDAINPUT;
+ SCLINPUT;
+}
+
+//! Inits bitbanging port, must be called before using the functions below
+void I2C_Init()
+{
+ I2C_Take();
+ //PULLON;
-// This is never called...
+// XXX This is never called...
I2C_CLOCK_LO();
I2CDELAY(1);
I2C_CLOCK_LO();
I2CDELAY(1);
-
- /*if(c>0)
- *I2C_DATA_LO();
- *
- *I2CDELAY(1);
- */
//! Send a START Condition
void I2C_Start()
{
//! Send a START Condition
void I2C_Start()
{
- // set both to high at the same time
- SETBOTH;
+ I2C_Take(); // XXX Should probably check to see if someone else is using the bus before we do this
I2CDELAY(3);
I2C_DATA_LO();
I2CDELAY(3);
I2C_DATA_LO();
I2C_DATA_HI();
I2CDELAY(1);
I2C_DATA_HI();
I2CDELAY(1);
}
//! write a byte to the I2C slave device
}
//! write a byte to the I2C slave device