lh79524_i2c_driver.h
来自「SHARP_ARM720T_LH79524/5软件开发包_支持TFT_LCD_N」· C头文件 代码 · 共 157 行
H
157 行
/***********************************************************************
* $Workfile: lh79524_i2c_driver.h $
* $Revision: 1.5 $
* $Author: TilburyC $
* $Date: Oct 14 2004 17:51:06 $
*
* Project: LH79524 chip definitions
*
* Description:
* This file contains the function and data declarations for the
* LH79524 I2C device driver.
*
* Revision History:
* $Log:: //smaicnt2/pvcs/VM/CHIPS/archives/software/csps/lh79524/inc$
*
* Rev 1.5 Oct 14 2004 17:51:06 TilburyC
* Changes to IOCTLS and other code to support the notion that the config register cannot be set up using IOCTLS
*
* Rev 1.4 Oct 13 2004 17:00:10 TilburyC
* Completed I2C device driver
*
* Rev 1.2 Oct 06 2004 17:35:06 TilburyC
* Working i2c driver
*
* Rev 1.1 Oct 01 2004 11:06:04 TilburyC
* many changes to implement drivers
*
* Rev 1.0 Sep 14 2004 15:37:14 TilburyC
* Initial revision.
*
*
***********************************************************************
*
* Copyright (c) 2004 Sharp Microelectronics of the Americas
*
* All rights reserved
*
* SHARP MICROELECTRONICS OF THE AMERICAS MAKES NO REPRESENTATION
* OR WARRANTIES WITH RESPECT TO THE PERFORMANCE OF THIS SOFTWARE,
* AND SPECIFICALLY DISCLAIMS ANY RESPONSIBILITY FOR ANY DAMAGES,
* SPECIAL OR CONSEQUENTIAL, CONNECTED WITH THE USE OF THIS SOFTWARE.
*
* SHARP MICROELECTRONICS OF THE AMERICAS PROVIDES THIS SOFTWARE SOLELY
* FOR THE PURPOSE OF SOFTWARE DEVELOPMENT INCORPORATING THE USE OF A
* SHARP MICROCONTROLLER OR SYSTEM-ON-CHIP PRODUCT. USE OF THIS SOURCE
* FILE IMPLIES ACCEPTANCE OF THESE CONDITIONS.
*
**********************************************************************/
#ifndef LH79524_I2C_DRIVER_H
#define LH79524_I2C_DRIVER_H
#include "lh79524_i2c.h"
#if defined __cplusplus
#if __cplusplus
extern "C"
{
#endif /* __cplusplus */
#endif /* __cplusplus */
/* default high and low count for 100kbps */
#define I2C_SLOW_LOW_COUNTER 0xF0
#define I2C_SLOW_HIGH_COUNTER 0xCC
/* default high and low count for 400kbps */
#define I2C_FAST_LOW_COUNTER 0x40
#define I2C_FAST_HIGH_COUNTER 0x1B
/*
flags to use with read or write functions
I2C_LAST_BYTE interacts with I2C_RSSEL. When last byte is set
rssel is clear, then a stop state is specified. If rssel is set,
then a restart state is set.
*/
#define I2C_STOP I2C_ICCON_STOP
#define I2C_RESTART (I2C_ICCON_SABT | I2C_ICCON_STOP)
/* Tells the controller that the next operation is a read */
#define I2C_READ I2C_ICCON_RWC
/* i2c configuration data structure used by open() */
typedef struct
{
UNS_32 mode; /* mode, i.e. 7 bit master */
UNS_32 speed; /* 400kHz = 1, 100kHz = 0 */
UNS_32 low_slave_addr; /* 7 bit slave address */
UNS_32 high_slave_addr; /* 10 bit slave address */
} I2C_CONFIG_T;
/* data structure used by ioctl to set/get timer information */
typedef struct
{
UNS_32 high_count; /* value of the high timer */
UNS_32 low_count; /* value of the low timer */
} I2C_COUNTER_T;
/* I2C ioctl (IO control) commands */
typedef enum
{
/* Return the current configuration in the config data structure. */
I2C_IOCTL_GET_CONFIG = 100,
/* Return the current status in the status data strucutre. */
I2C_IOCTL_GET_STATUS,
/* Set the configuration using the config data structure. */
I2C_IOCTL_SET_CONFIG_EX,
/* Set the speed bit and the timer registers using the i2c speed
data structure. */
I2C_IOCTL_SET_SPEED,
/* Return the speed data strucutre in the buffer provided. */
I2C_IOCTL_GET_SPEED,
/* Wait (spin) until the i2c interface is idle */
I2C_IOCTL_WAIT_IDLE,
/* Return the number of transmit aborts that have taken place since the
driver was opened. */
I2C_IOCTL_GET_TXABORTS,
/* Return the number of recieve aborts that have taken place since the
driver was opened. */
I2C_IOCTL_GET_RXABORTS,
/* Return the number of reads that have taken place since the
driver was opened. */
I2C_IOCTL_GET_READS,
/* Return the number of writes that have taken place since the
driver was opened. */
I2C_IOCTL_GET_WRITES,
/* return the number of interrupts that taken place sine the driver
was opened. */
I2C_IOCTL_GET_INTERRUPTS,
/* Return a pointer to the ISR routine */
I2C_IOCTL_GET_ISR,
/* set all of the status counters back to 0 */
I2C_IOCTL_RESET_STATS,
/* Switch between using polling and interrupts. Default is
polling. */
I2C_IOCTL_ENA_POLLING,
I2C_IOCTL_ENA_INTERRUPT,
/* set the high/low counters */
I2C_IOCTL_SET_COUNTER,
/* get the high/low counters */
I2C_IOCTL_GET_COUNTER
} I2C_IOCTLS_T;
/* Unix style API */
extern INT_32 i2c_open (INT_32 ipbase, INT_32 arg);
extern STATUS i2c_close (INT_32 devid);
extern INT_32 i2c_read (INT_32 devid, CHAR* byte, UNS_32 attrib);
extern INT_32 i2c_write (INT_32 devid, CHAR byte, UNS_32 attrib);
extern STATUS i2c_ioctl (INT_32 devid, I2C_IOCTLS_T cmd, UNS_32 arg);
#if defined __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* LH79524_I2C_DRIVER_H */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?