This section provides high level APIs to upper layer.  
More...
This section provides high level APIs to upper layer. 
|  | 
| int | mtk_os_hal_i2c_ctrl_init (i2c_num bus_num) | 
|  | Init I2C controller.  More... 
 | 
|  | 
| int | mtk_os_hal_i2c_ctrl_deinit (i2c_num bus_num) | 
|  | Deinit I2C controller.  More... 
 | 
|  | 
| int | mtk_os_hal_i2c_speed_init (i2c_num bus_num, enum i2c_speed_kHz speed) | 
|  | Initialize i2c master transfer speed.  More... 
 | 
|  | 
| int | mtk_os_hal_i2c_read (i2c_num bus_num, u8 device_addr, u8 *buffer, u16 len) | 
|  | I2C master read data from slave device.  More... 
 | 
|  | 
| int | mtk_os_hal_i2c_write (i2c_num bus_num, u8 device_addr, u8 *buffer, u16 len) | 
|  | I2C master write data to slave device.  More... 
 | 
|  | 
| int | mtk_os_hal_i2c_write_read (i2c_num bus_num, u8 device_addr, u8 *wr_buf, u8 *rd_buf, u16 wr_len, u16 rd_len) | 
|  | I2C master write data to slave device then read data from device.  More... 
 | 
|  | 
| int | mtk_os_hal_i2c_set_slave_addr (i2c_num bus_num, u8 slv_addr) | 
|  | Set I2C slave address before transfer when I2C hardware controller is set as a slave role, it which means does not call this function when hardware is set as an I2C master role.  More... 
 | 
|  | 
| int | mtk_os_hal_i2c_slave_tx (i2c_num bus_num, u8 *buffer, u16 len, u32 time_out) | 
|  | I2C slave wait for master to trigger transfer and then send data to the master.  More... 
 | 
|  | 
| int | mtk_os_hal_i2c_slave_rx (i2c_num bus_num, u8 *buffer, u16 len, u32 time_out) | 
|  | I2C slave wait for master to trigger transfer and then receive data from the master.  More... 
 | 
|  | 
      
        
          | int mtk_os_hal_i2c_ctrl_init | ( | i2c_num | bus_num | ) |  | 
      
 
Init I2C controller. 
- Parameters
- 
  
    | [in] | bus_num | : I2C ISU Port number, it can be OS_HAL_I2C_ISU0~OS_HAL_I2C_ISU4 |  
 
- Returns
- negative value means fail. 
- 
0 means success. 
 
 
      
        
          | int mtk_os_hal_i2c_ctrl_deinit | ( | i2c_num | bus_num | ) |  | 
      
 
Deinit I2C controller. 
- Parameters
- 
  
    | [in] | bus_num | : I2C ISU Port number, it can be OS_HAL_I2C_ISU0~OS_HAL_I2C_ISU4 |  
 
- Returns
- negative value means fail. 
- 
0 means success. 
 
 
Initialize i2c master transfer speed. 
- Parameters
- 
  
    | [in] | bus_num | : I2C ISU Port number, it can be OS_HAL_I2C_ISU0~OS_HAL_I2C_ISU4 |  | [in] | i2c_speed_kHz | : It can be set to one of the enum i2c_speed_kHz. |  
 
- Returns
- "0" if I2C sets speed successfully.
 
- 
-I2C_EPTR if i2c is NULL.
 
- 
-I2C_EINVAL if a parameter is invalid. 
 
 
      
        
          | int mtk_os_hal_i2c_read | ( | i2c_num | bus_num, | 
        
          |  |  | u8 | device_addr, | 
        
          |  |  | u8 * | buffer, | 
        
          |  |  | u16 | len | 
        
          |  | ) |  |  | 
      
 
I2C master read data from slave device. 
- Parameters
- 
  
    | [in] | bus_num | : I2C ISU Port number, it can be OS_HAL_I2C_ISU0~OS_HAL_I2C_ISU4. |  | [in] | device_addr | : slave device address. |  | [in] | buffer | : read data buffer. |  | [in] | len | : read data length. |  
 
- Returns
- negative value means fail.
- 
"0" if I2C read data from slave device successfully. 
 
 
      
        
          | int mtk_os_hal_i2c_write | ( | i2c_num | bus_num, | 
        
          |  |  | u8 | device_addr, | 
        
          |  |  | u8 * | buffer, | 
        
          |  |  | u16 | len | 
        
          |  | ) |  |  | 
      
 
I2C master write data to slave device. 
- Parameters
- 
  
    | [in] | bus_num | : I2C ISU Port number, it can be OS_HAL_I2C_ISU0~OS_HAL_I2C_ISU4. |  | [in] | device_addr | : slave device address. |  | [in] | buffer | : write data buffer. |  | [in] | len | : write data length. |  
 
- Returns
- negative value means fail.
- 
"0" if I2C write data to slave device successfully. 
 
 
      
        
          | int mtk_os_hal_i2c_write_read | ( | i2c_num | bus_num, | 
        
          |  |  | u8 | device_addr, | 
        
          |  |  | u8 * | wr_buf, | 
        
          |  |  | u8 * | rd_buf, | 
        
          |  |  | u16 | wr_len, | 
        
          |  |  | u16 | rd_len | 
        
          |  | ) |  |  | 
      
 
I2C master write data to slave device then read data from device. 
- Parameters
- 
  
    | [in] | bus_num | : I2C ISU Port number, it can be OS_HAL_I2C_ISU0~OS_HAL_I2C_ISU4. |  | [in] | device_addr | : slave device address. |  | [in] | wr_buf | : write data buffer. |  | [in] | rd_buf | : read data buffer. |  | [in] | wr_len | : write data length. |  | [in] | rd_len | : read data length. |  
 
- Returns
- negative value means fail.
- 
"0" if I2C write data to slave device successfully. 
 
 
      
        
          | int mtk_os_hal_i2c_set_slave_addr | ( | i2c_num | bus_num, | 
        
          |  |  | u8 | slv_addr | 
        
          |  | ) |  |  | 
      
 
Set I2C slave address before transfer when I2C hardware controller is set as a slave role, it which means does not call this function when hardware is set as an I2C master role. 
- Parameters
- 
  
    | [in] | bus_num | : I2C ISU Port number, it can be OS_HAL_I2C_ISU0~OS_HAL_I2C_ISU4. |  | [in] | slv_addr | : Set controller slave address. |  
 
- Returns
- "0" if I2C sets slave address successfully.
 
- 
-I2C_EPTR if i2c is NULL.
 -I2C_EINVAL If a parameter is invalid then I2C slave address uses 0x20 by default.
 
 
      
        
          | int mtk_os_hal_i2c_slave_tx | ( | i2c_num | bus_num, | 
        
          |  |  | u8 * | buffer, | 
        
          |  |  | u16 | len, | 
        
          |  |  | u32 | time_out | 
        
          |  | ) |  |  | 
      
 
I2C slave wait for master to trigger transfer and then send data to the master. 
- Parameters
- 
  
    | [in] | bus_num | : I2C ISU Port number, it can be OS_HAL_I2C_ISU0~OS_HAL_I2C_ISU4. |  | [in] | buffer | : send data buffer. |  | [in] | len | : i2c slave send data length. |  | [in] | time_out | : i2c slave waiting time. |  
 
- Returns
- negative value means fail.
- 
"0" if i2c send data to master successfully. 
 
 
      
        
          | int mtk_os_hal_i2c_slave_rx | ( | i2c_num | bus_num, | 
        
          |  |  | u8 * | buffer, | 
        
          |  |  | u16 | len, | 
        
          |  |  | u32 | time_out | 
        
          |  | ) |  |  | 
      
 
I2C slave wait for master to trigger transfer and then receive data from the master. 
- Parameters
- 
  
    | [in] | bus_num | : I2C ISU Port number, it can be OS_HAL_I2C_ISU0~OS_HAL_I2C_ISU4. |  | [in] | buffer | : receive data buffer. |  | [in] | len | : i2c slave receive data length. |  | [in] | time_out | : i2c slave waiting time. |  
 
- Returns
- negative value means fail.
- 
"0" if i2c receive data from master successfully.