1 /*******************************************************************
3 * Copyright (c) 2007 by Silicon Motion, Inc. (SMI)
5 * All rights are reserved. Reproduction or in part is prohibited
6 * without the written consent of the copyright owner.
8 * swi2c.h --- SM750/SM718 DDK
9 * This file contains the definitions for i2c using software
12 *******************************************************************/
16 /* Default i2c CLK and Data GPIO. These are the default i2c pins */
17 #define DEFAULT_I2C_SCL 30
18 #define DEFAULT_I2C_SDA 31
21 * This function initializes the i2c attributes and bus
24 * i2cClkGPIO - The GPIO pin to be used as i2c SCL
25 * i2cDataGPIO - The GPIO pin to be used as i2c SDA
28 * -1 - Fail to initialize the i2c
32 unsigned char i2cClkGPIO,
33 unsigned char i2cDataGPIO
37 * This function reads the slave device's register
40 * deviceAddress - i2c Slave device address which register
42 * registerIndex - Slave device's register to be read
47 unsigned char swI2CReadReg(
48 unsigned char deviceAddress,
49 unsigned char registerIndex
53 * This function writes a value to the slave device's register
56 * deviceAddress - i2c Slave device address which register
58 * registerIndex - Slave device's register to be written
59 * data - Data to be written to the register
66 unsigned char deviceAddress,
67 unsigned char registerIndex,
72 * These two functions are used to toggle the data on the SCL and SDA I2C lines.
73 * The used of these two functions are not recommended unless it is necessary.
77 * This function set/reset the SCL GPIO pin
80 * value - Bit value to set to the SCL or SDA (0 = low, 1 = high)
82 void swI2CSCL(unsigned char value);
85 * This function set/reset the SDA GPIO pin
88 * value - Bit value to set to the SCL or SDA (0 = low, 1 = high)
90 void swI2CSDA(unsigned char value);
92 #endif /* _SWI2C_H_ */