diff --git a/src/add-ons/accelerants/nvidia/engine/nv_i2c.c b/src/add-ons/accelerants/nvidia/engine/nv_i2c.c index 1e12005f7a..bb7979f814 100644 --- a/src/add-ons/accelerants/nvidia/engine/nv_i2c.c +++ b/src/add-ons/accelerants/nvidia/engine/nv_i2c.c @@ -9,7 +9,7 @@ * * Other authors: * Mark Watson 6/2000, - * Rudolf Cornelissen 12/2002-12/2003 + * Rudolf Cornelissen 12/2002-9/2005 */ #define MODULE_BIT 0x00004000 @@ -25,7 +25,6 @@ void i2c_low(void); int i2c_get_ack(void); void i2c_send_ack(void); int i2c_sendbyte(unsigned char data); -unsigned char i2c_readbyte(int ack_required); /*which device on the bus is the MAVEN?*/ #define MAVEN_WRITE (0x1B<<1) @@ -263,40 +262,141 @@ int i2c_sendbyte(unsigned char data) return i2c_get_ack(); } -unsigned char i2c_readbyte(int ack_required) +//rud's betvout: +static char FlagIICError (char ErrNo) +//error code list: +//1 - SCL locked low by device (bus is still busy) +//2 - SDA locked low by device (bus is still busy) +//3 - No Acknowledge from device (no handshake) +//4 - SDA not released for master to generate STOP bit { - int i; - unsigned char data=0; - - /*read data*/ - i2c_set_lines(0,1); - for (i=7; i>=0; i--) - { - i2c_set_lines(1,1); - if (i2c_get_data()==1) - data |= (1< 0; cnt--) + { + byte <<= 1; + bit = RXBit (BusNR); + byte += bit; + } + /* send acknowledge */ + TXBit (BusNR, Ack); + + LOG(4,("I2C: read byte ($%02x) from bus #%d; status is %d\n", + byte, BusNR, FlagIICError(0))); + + return byte; +} +//end rud. + /*------------------------------------------- *PUBLIC functions */ int i2c_maven_read(unsigned char address) { int error=0; - int data; + int data=0; i2c_start(); { error+=i2c_sendbyte(MAVEN_READ); error+=i2c_sendbyte(address); - data = i2c_readbyte(0); +// data = i2c_readbyte(0); } i2c_stop(); if (error>0) LOG(8,("I2C: MAVR ERROR - %x\n",error));