Enclosed you can find TransChip I2C SW driver.
It is a generic driver. For it to work, you first have to fill in the blank functions in the cami2c.c file.
The functions that have to be filled in are listed in the following table:
|
Function |
What it has to do |
|
void SETINPUT_SDA (void) |
Sets the SDA (data) pin to input |
|
void SETOUTPUT_SDA (void) |
Sets the SDA (data) pin to output |
|
void SETINPUT_SCL (void) |
Sets the SCL (clock) pin to input |
|
void SETOUTPUT_SCL (void) |
Sets the SCL(clock) pin to output |
|
void SET_SCL(void) |
Sets the SCL(clock) pin to high state |
|
void CLEAR_SCL(void) |
Sets the SCL(clock) pin to low state |
|
void SET_SDA(void) |
Sets the SDA(data) pin to high state |
|
void CLEAR_SDA(void) |
Sets the SDA(data) pin to low state |
|
unsigned char READ_SDA(void) |
Reads the SDA pin state. Returns 1 if it is high, or 0 if it is low |
|
|
|
The reason these function are left blank and have to be filled in is that they are hardware specific. That is – for each system there will be different implementation of GPIO and different mode of controlling the GPIOs, so it is impossible to write one function that will suit all systems.
After you have finished filling the functions, add the following code to hostfunction.c file:
int HostTCTransferDataProc( void* pBuffer,
unsigned short usBufferSize,
TC_ACCESS_TYPE tcAccessType )
{
return I2C_swTransfer( TC5640_I2C_ADDRESS,
pBuffer,
usBufferSize,
tcAccessType == TC_WRITE ) ;
}