📄 iic_api.h
字号:
#ifndef IIC_API_H
#define IIC_API_H
/************************************************************************
*
* IIC_api.h
*
* The 'IIC_api' module defines the IIC device driver
* interface to be used via 'IIC' device driver services:
*
* 1) init serial device: configure and initialize IIC driver
* 2) open serial device: not used
* 3) close serial device: not used
* 4) read serial device: read IIC device
* 5) write serial device: write IIC device
* 6) ctrl serial device: a) write+read IIC device
* b) test IIC device
*
*
*
* ######################################################################
*
* Copyright (c) 1999-2000 MIPS Technologies, Inc. All rights reserved.
*
* Unpublished rights reserved under the Copyright Laws of the United States of
* America.
*
* This document contains information that is proprietary to MIPS Technologies,
* Inc. ("MIPS Technologies"). Any copying, modifying or use of this information
* (in whole or in part) which is not expressly permitted in writing by MIPS
* Technologies or a contractually-authorized third party is strictly
* prohibited. At a minimum, this information is protected under unfair
* competition laws and the expression of the information contained herein is
* protected under federal copyright laws. Violations thereof may result in
* criminal penalties and fines.
* MIPS Technologies or any contractually-authorized third party reserves the
* right to change the information contained in this document to improve
* function, design or otherwise. MIPS Technologies does not assume any
* liability arising out of the application or use of this information. Any
* license under patent rights or any other intellectual property rights owned
* by MIPS Technologies or third parties shall be conveyed by MIPS Technologies
* or any contractually-authorized third party in a separate license agreement
* between the parties.
* The information contained in this document constitutes one or more of the
* following: commercial computer software, commercial computer software
* documentation or other commercial items. If the user of this information, or
* any related documentation of any kind, including related technical data or
* manuals, is an agency, department, or other entity of the United States
* government ("Government"), the use, duplication, reproduction, release,
* modification, disclosure, or transfer of this information, or any related
* documentation of any kind, is restricted in accordance with Federal
* Acquisition Regulation 12.212 for civilian agencies and Defense Federal
* Acquisition Regulation Supplement 227.7202 for military agencies. The use of
* this information by the Government is further restricted in accordance with
* the terms of the license agreement(s) and/or applicable contract terms and
* conditions covering this information from MIPS Technologies or any
* contractually-authorized third party.
*
************************************************************************/
/************************************************************************
* Include files
************************************************************************/
#include "sysdefs.h"
#include "syserror.h"
/************************************************************************
* IIC device driver, ERROR completion codes
*************************************************************************/
typedef enum IIC_error_ids
{
ERROR_IIC_COMM_ERROR /* Communication error detected */
= ERROR_IIC,
ERROR_IIC_ADDRESS_ERROR, /* Address error */
ERROR_IIC_DATA_ERROR, /* Data error */
ERROR_IIC_TIMEOUT, /* Timeout */
ERROR_IIC_UNKNOWN_COMMAND, /* Unknown ctrl command */
/******* ADD NEW IO ERROR TAGS JUST BEFORE THIS LINE ONLY *******/
} t_IIC_error_ids;
/************************************************************************
* IIC 'ctrl' service, command codes
*************************************************************************/
typedef enum IIC_ctrl_command_ids
{
IIC_CTRL_WRITE_READ = 0, /* Write Read command */
IIC_CTRL_TEST, /* Test command */
} t_IIC_ctrl_command_ids;
/************************************************************************
* Parameter definitions
*************************************************************************/
/*
IIC read descriptor, to be used with IIC-'read' service
*/
typedef struct IIC_read_descriptor
{
UINT8 IICaddress ; /* 7-bit IIC slave address */
UINT8 length ; /* number of bytes to read */
UINT8 *buffer ; /* pointer for buffer to store read data */
} t_IIC_read_descriptor ;
/*
IIC write descriptor, to be used with IIC-'write' service
*/
typedef struct IIC_write_descriptor
{
UINT8 IICaddress ; /* 7-bit IIC slave address */
UINT8 length ; /* number of bytes to write */
UINT8 *buffer ; /* pointer for buffer to be written */
} t_IIC_write_descriptor ;
/*
IIC write-read descriptor, to be used with IIC-'write_read' service
*/
typedef struct IIC_write_read_descriptor
{
UINT8 write_length ; /* number of bytes to write */
UINT8 *write_buffer ; /* pointer for buffer to be written */
UINT8 read_length ; /* number of bytes to read */
UINT8 *read_buffer ; /* pointer for buffer to store read data */
} t_IIC_write_read_descriptor ;
/*
IIC ctrl descriptor, to be used with aggregated IIC services
*/
typedef struct IIC_ctrl_descriptor
{
UINT8 IICaddress ; /* 7-bit IIC slave address */
UINT8 command ; /* 'ctrl' command */
void *data ; /* specific data per command */
} t_IIC_ctrl_descriptor ;
/************************************************************************
* IIC device driver services, called by IO subsystem
*************************************************************************/
/*
NAME: 'init'
DESCRIPTION:
This service initializes the IIC driver and configures
the IIC-bus speed via the 'syscon' parameter:
'SYSCON_COM_IIC_BAUDRATE_ID'
RETURN VALUES:
'OK' = 0x00
*/
typedef INT32 (*t_IIC_init_service)(
UINT32 major, /* IN: major device number */
UINT32 minor, /* not used */
void *p_param ) ; /* not used */
/*
NAME: 'open' NOT USED
DESCRIPTION:
-
RETURN VALUES:
-
*/
/*
NAME: 'close' NOT USED
DESCRIPTION:
-
RETURN VALUES:
-
*/
/*
NAME: 'read'
DESCRIPTION:
This service reads data from the specified IIC device into the
user allocated variable, *p_param.
RETURN VALUES:
'OK' = 0x00: IIC device data read into user variable
'ERROR_IIC_COMM_ERROR': communication error detected
*/
typedef INT32 (*t_IIC_read_service)(
UINT32 major, /* IN: major device number */
UINT32 minor, /* IN: minor device number */
t_IIC_read_descriptor *p_param ) ; /* IN: IIC device data */
/*
NAME: 'write'
DESCRIPTION:
This service writes user data to the specified IIC device.
RETURN VALUES:
'OK' = 0x00: data written to IIC device
'ERROR_IIC_COMM_ERROR': communication error detected
*/
typedef INT32 (*t_IIC_write_service)(
UINT32 major, /* IN: major device number */
UINT32 minor, /* IN: minor device number */
t_IIC_write_descriptor *p_param ) ; /* OUT: IIC device data */
/*
NAME: 'ctrl'
DESCRIPTION:
This service comprise following aggregated IIC services:
1) 'write_read' IIC device.
1) 'test' IIC device.
RETURN VALUES:
'OK' = 0x00: IIC service completed successfully
'ERROR_IIC_COMM_ERROR': communication error detected
*/
typedef INT32 (*t_IIC_ctrl_service)(
UINT32 major, /* IN: major device number */
UINT32 minor, /* IN: minor device number */
t_IIC_ctrl_descriptor *p_param ) ; /* INOUT: IIC device data */
#endif /* #ifndef IIC_API_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -