2 * Copyright (C) 2013 Realtek Semiconductor Corp.
5 * Unless you and Realtek execute a separate written software license
6 * agreement governing use of this software, this software is licensed
7 * to you under the terms of the GNU General Public License version 2,
8 * available at https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
10 * Purpose : RTL8367/RTL8367C switch high-level API
12 * Feature : The file includes I2C module high-layer API defination
17 #ifndef __RTK_API_I2C_H__
18 #define __RTK_API_I2C_H__
19 #include <rtk_types.h>
21 #define I2C_GPIO_MAX_GROUP (3)
23 typedef enum rtk_I2C_16bit_mode_e
{
24 I2C_LSB_16BIT_MODE
= 0,
25 I2C_70B_LSB_16BIT_MODE
,
27 }rtk_I2C_16bit_mode_t
;
30 typedef enum rtk_I2C_gpio_pin_e
{
41 * read i2c slave device register.
43 * deviceAddr - access Slave device address
44 * slaveRegAddr - access Slave register address
46 * pRegData - read data
49 * RT_ERR_NULL_POINTER - input parameter is null pointer
51 * The API can access i2c slave and read i2c slave device register.
53 extern rtk_api_ret_t
rtk_i2c_data_read(rtk_uint8 deviceAddr
, rtk_uint32 slaveRegAddr
, rtk_uint32
*pRegData
);
58 * write data to i2c slave device register
60 * deviceAddr - access Slave device address
61 * slaveRegAddr - access Slave register address
62 * regData - data to set
68 * The API can access i2c slave and setting i2c slave device register.
70 extern rtk_api_ret_t
rtk_i2c_data_write(rtk_uint8 deviceAddr
, rtk_uint32 slaveRegAddr
, rtk_uint32 regData
);
76 * I2C smart function initialization.
83 * RT_ERR_FAILED - Failed
85 * This API is used to initialize EEE status.
89 extern rtk_api_ret_t
rtk_i2c_init(void);
94 * Set I2C data byte-order.
96 * i2cmode - byte-order mode
101 * RT_ERR_FAILED - Failed
102 * RT_ERR_INPUT - Invalid input parameter.
104 * This API can set I2c traffic's byte-order .
106 extern rtk_api_ret_t
rtk_i2c_mode_set( rtk_I2C_16bit_mode_t i2cmode
);
111 * Get i2c traffic byte-order setting.
115 * pI2cMode - i2c byte-order
118 * RT_ERR_FAILED - Failed
119 * RT_ERR_NULL_POINTER - input parameter is null pointer
121 * The API can get i2c traffic byte-order setting.
123 extern rtk_api_ret_t
rtk_i2c_mode_get( rtk_I2C_16bit_mode_t
* pI2cMode
);
127 * rtk_i2c_gpioPinGroup_set
129 * Set i2c SDA & SCL used GPIO pins group.
131 * pins_group - GPIO pins group
136 * RT_ERR_FAILED - Failed
137 * RT_ERR_INPUT - Invalid input parameter.
139 * The API can set i2c used gpio pins group.
140 * There are three group pins could be used
142 extern rtk_api_ret_t
rtk_i2c_gpioPinGroup_set( rtk_I2C_gpio_pin_t pins_group
);
145 * rtk_i2c_gpioPinGroup_get
147 * Get i2c SDA & SCL used GPIO pins group.
151 * pPins_group - GPIO pins group
154 * RT_ERR_NULL_POINTER - input parameter is null pointer
156 * The API can get i2c used gpio pins group.
157 * There are three group pins could be used
159 extern rtk_api_ret_t
rtk_i2c_gpioPinGroup_get(rtk_I2C_gpio_pin_t
* pPins_group
);