added more I2C stuff (in progress)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14241 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Rudolf Cornelissen
2005-09-25 17:48:04 +00:00
parent 3df611d78d
commit d1d567ab21
+42 -9
View File
@@ -281,9 +281,6 @@ static void OutSCL(uint8 BusNR, bool Bit)
{ {
uint8 data; uint8 data;
/* enable access to primary head */
set_crtc_owner(0);
if (BusNR) if (BusNR)
{ {
data = (CRTCR(WR_I2CBUS_1) & 0xf0) | 0x01; data = (CRTCR(WR_I2CBUS_1) & 0xf0) | 0x01;
@@ -294,7 +291,7 @@ static void OutSCL(uint8 BusNR, bool Bit)
} }
else else
{ {
data = CRTCR(WR_I2CBUS_0) & 0xf0; data = (CRTCR(WR_I2CBUS_0) & 0xf0) | 0x01;
if (Bit) if (Bit)
CRTCW(WR_I2CBUS_0, (data | 0x20)); CRTCW(WR_I2CBUS_0, (data | 0x20));
else else
@@ -304,19 +301,52 @@ static void OutSCL(uint8 BusNR, bool Bit)
static void OutSDA(uint8 BusNR, bool Bit) static void OutSDA(uint8 BusNR, bool Bit)
{ {
//fixme.. uint8 data;
if (BusNR)
{
data = (CRTCR(WR_I2CBUS_1) & 0xf0) | 0x01;
if (Bit)
CRTCW(WR_I2CBUS_1, (data | 0x10));
else
CRTCW(WR_I2CBUS_1, (data & ~0x10));
}
else
{
data = (CRTCR(WR_I2CBUS_0) & 0xf0) | 0x01;
if (Bit)
CRTCW(WR_I2CBUS_0, (data | 0x10));
else
CRTCW(WR_I2CBUS_0, (data & ~0x10));
}
} }
static bool InSCL(uint8 BusNR) static bool InSCL(uint8 BusNR)
{ {
//fixme.. if (BusNR)
return 0; {
if ((CRTCR(RD_I2CBUS_1) & 0x04)) return true;
}
else
{
if ((CRTCR(RD_I2CBUS_0) & 0x04)) return true;
}
return false;
} }
static bool InSDA(uint8 BusNR) static bool InSDA(uint8 BusNR)
{ {
//fixme.. if (BusNR)
return 0; {
if ((CRTCR(RD_I2CBUS_1) & 0x08)) return true;
}
else
{
if ((CRTCR(RD_I2CBUS_0) & 0x08)) return true;
}
return false;
} }
static void TXBit (uint8 BusNR, bool Bit) static void TXBit (uint8 BusNR, bool Bit)
@@ -367,6 +397,9 @@ static uint8 i2c_readbyte(uint8 BusNR, bool Ack)
{ {
uint8 cnt, bit, byte = 0; uint8 cnt, bit, byte = 0;
/* enable access to primary head */
set_crtc_owner(0);
/* read data */ /* read data */
for (cnt = 8; cnt > 0; cnt--) for (cnt = 8; cnt > 0; cnt--)
{ {