1/****************************************************************************** 2/ 3/ File: I2C.h 4/ 5/ Description: ATI Radeon I2C Serial Bus interface. 6/ 7/ Copyright 2001, Carlos Hasan 8/ 9*******************************************************************************/ 10 11#ifndef __I2C_PORT_H__ 12#define __I2C_PORT_H__ 13 14#include "Radeon.h" 15 16enum i2c_port_clock_rate { 17 C_RADEON_I2C_MIN_CLOCK_RATE = 7500, 18 C_RADEON_I2C_MAX_CLOCK_RATE = 100000, 19 C_RADEON_I2C_DEFAULT_CLOCK_RATE = 80000 20}; 21 22class CI2CPort { 23public: 24 CI2CPort(CRadeon & radeon, int rate = C_RADEON_I2C_DEFAULT_CLOCK_RATE); 25 26 ~CI2CPort(); 27 28 status_t InitCheck() const; 29 30 CRadeon & Radeon() const; 31 32 bool Probe(int address); 33 34public: 35 bool Write(int address, const char * buffer, int length); 36 37 bool Read(int address, char * buffer, int length); 38 39 bool Write(int address, const char * buffer, int length, char * output, int outlen); 40 41public: 42 int Register(int address, int index); 43 44 void SetRegister(int address, int index, int value); 45 46private: 47 int Send(int address, const char * buffer, int length, bool start, bool stop); 48 49 int Receive(int address, char * buffer, int length, bool start, bool stop); 50 51 int WaitAck(); 52 53 void Stop(); 54 55private: 56 CRadeon & fRadeon; 57 int fNfactor; 58 int fMfactor; 59 int fTimeLimit; 60 shared_info* si; 61}; 62 63 64#endif 65