You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
4.2 KiB

/*
* Copyright (c) Hisilicon Technologies Co., Ltd.. 2004-2019. All rights reserved.
* Description:user space api func
*/
#include "uapi_i2c.h"
#include "mpi_i2c_ext.h"
/******************************************************
Function: uapi_i2c_init
Description: init i2c device
Data Accessed: NA
Data Updated: NA
Input: NA
Output: NA
Return: ErrorCode(reference to document)
Others: NA
*******************************************************/
td_s32 uapi_i2c_init(td_void)
{
return ext_mpi_i2c_init();
}
/*******************************************************
Function: uapi_i2c_deinit
Description: deinit i2c device
Data Accessed: NA
Data Updated: NA
Input: NA
Output: NA
Return: ErrorCode(reference to document)
Others: NA
********************************************************/
td_s32 uapi_i2c_deinit(td_void)
{
return ext_mpi_i2c_deinit();
}
/*********************************************************************************************
Function: uapi_i2c_get_total_num
Description: Call this API to get the number of I2C module befor read/write data
Calls: NA
Data Accessed: NA
Data Updated: NA
Input: NA
Output: i2c_num - the number of I2C module
Return: ErrorCode(reference to document)
Others: NA
**********************************************************************************************/
td_s32 uapi_i2c_get_total_num(td_u32 *i2c_num)
{
return ext_mpi_i2c_get_total_num(i2c_num);
}
/******************************************************
Function: uapi_i2c_read
Description: read data via i2c
Data Accessed: NA
Data Updated: NA
Input: NA
Output: NA
Return: ErrorCode(reference to document)
Others: NA
*******************************************************/
td_s32 uapi_i2c_read(td_u32 i2c_id, const uapi_i2c_addr_info *i2c_addr_info, td_u8 *buf, td_u32 length)
{
return ext_mpi_i2c_read(i2c_id, (const ext_i2c_addr_info *)i2c_addr_info, buf, length);
}
/*******************************************
Function: uapi_i2c_write
Description: write data via i2c
Data Accessed: NA
Data Updated: NA
Input: NA
Output: NA
Return: ErrorCode(reference to document)
Others: NA
*******************************************/
td_s32 uapi_i2c_write(td_u32 i2c_id, const uapi_i2c_addr_info *i2c_addr_info, td_u8 *buf, td_u32 length)
{
return ext_mpi_i2c_write(i2c_id, (const ext_i2c_addr_info *)i2c_addr_info, buf, length);
}
/*******************************************
Function: uapi_i2c_create_gpio_i2c
Description: config param
Data Accessed: NA
Data Updated: NA
Input: NA
Output: NA
Return: ErrorCode(reference to document)
Others: NA
*******************************************/
td_s32 uapi_i2c_create_gpio_i2c(td_u32 scl_gpio_group, td_u32 scl_gpio_bit,
td_u32 sda_gpio_group, td_u32 sda_gpio_bit, td_u32 *i2c_id)
{
return ext_mpi_i2c_create_gpio_i2c(scl_gpio_group, scl_gpio_bit, sda_gpio_group, sda_gpio_bit, i2c_id);
}
/*******************************************
Function: uapi_i2c_destroy_gpio_i2c
Description: config param
Data Accessed: NA
Data Updated: NA
Input: NA
Output: NA
Return: ErrorCode(reference to document)
Others: NA
*******************************************/
td_s32 uapi_i2c_destroy_gpio_i2c(td_u32 i2c_id)
{
return ext_mpi_i2c_destroy_gpio_i2c(i2c_id);
}
/*******************************************************
Function: uapi_i2c_set_rate
Description: set the rate
Data Accessed: NA
Data Updated: NA
Input: NA
Output: NA
Return: ErrorCode(reference to document)
Others: NA
********************************************************/
td_s32 uapi_i2c_set_rate(td_u32 i2c_id, td_u32 rate_kbps)
{
return ext_mpi_i2c_set_rate(i2c_id, rate_kbps);
}