?? ioexpander.h
字號:
/****************************************************************************/
/* TEXAS INSTRUMENTS PROPRIETARY INFORMATION */
/* */
/* (c) Copyright, Texas Instruments Incorporated, 2006. */
/* All Rights Reserved. */
/* */
/* Property of Texas Instruments Incorporated. Restricted Rights - */
/* Use, duplication, or disclosure is subject to restrictions set */
/* forth in TI's program license agreement and associated documentation. */
/****************************************************************************/
/****************************************************************************/
/* ioExpander.h */
/* */
/* External IO expander device interface. */
/****************************************************************************/
#ifndef __IOEXPANDER_H
#define __IOEXPANDER_H
#include <stddef.h>
#include "common.h"
#include "i2c.h"
#include "iox.h"
/****************************************************************************/
/* Public IOX constants and macros. */
/* */
/****************************************************************************/
/****************************************************/
/* I2C Interface device types. */
/****************************************************/
typedef enum
{
IOXTYPE_PCF8574A,
IOXTYPE_PCA9539
}
IOXTYPE;
/****************************************************/
/* IO Point definitions. */
/****************************************************/
#define MAXPIN 32 /* maximum number of controllable pins */
#define IOX_IN 0x80 /* defines point as an input */
#define IOX_OUT 0x00 /* defines point as an output */
#define IOX_TRUE 0x40 /* defines pin state TRUE */
#define IOX_FALSE 0x00 /* defines pin state FALSE */
#define IOX_PINMASK 0x3f /* masks pin number in an IO point cfg */
/****************************************************/
/* Define a point configuration from pin, dir, val. */
/****************************************************/
#define IOX_PINCFG( pin, dir, val ) (( IOX_PINMASK & pin ) | ( dir ) | ( val ? IOX_TRUE : IOX_FALSE ))
/****************************************************/
/* Extract pin, dir, val from a point configuration */
/****************************************************/
#define IOX_GETPIN( pointcfg ) ( pointcfg & IOX_PINMASK )
#define IOX_GETDIR( pointcfg ) ( pointcfg & IOX_IN )
#define IOX_GETVAL( pointcfg ) ( IOX_TRUE == ( pointcfg & IOX_TRUE ))
/****************************************************/
/* IOX function completion codes. */
/****************************************************/
typedef enum
{
IOXCC_FAIL, /* general fail indication */
IOXCC_PASS, /* pass */
IOXCC_DEVTYPE, /* invalid device type */
IOXCC_PINNO, /* invalid pin count or pin number */
IOXCC_NOTOPEN, /* driver not open */
IOXCC_PORTCFG, /* invalid port configuration */
IOXCC_APIERROR /* error in API call */
}
IOXCC;
/****************************************************/
/* IOX driver initialization structure. */
/****************************************************/
typedef struct
{
IOXTYPE xType; /* driver type */
I2CPORT xPort; /* ASIC i2c controller port */
int08 xNumPins; /* number of external points */
uint32 xTimeout; /* semaphore timeout (milliseconds) */
}
IOXINITSTRUCT;
/****************************************************/
/* Expander bit direction and state bitfields. */
/* */
/* Shared between the peripheral interface and the */
/* expander device drivers to eliminate i2c reads */
/* to obtain current configuration and state. */
/****************************************************/
extern uint32 ioxDirection; /* direction bitfield: 0=output, 1=input */
extern uint32 ioxState; /* state bitfield */
/****************************************************************************/
/* IO expander common application functions. */
/****************************************************************************/
EXEC_CC_ENUM iox_init( void ); /* reset-time initialization */
IOXCC iox_open( IOXINITSTRUCT *pInit ); /* open IO expander peripheral */
IOXCC iox_cfgGet( int08 pin, uint08 *pPinCfg ); /* get an IOX point cfg */
IOXCC iox_cfgSet( uint08 pinCfg ); /* configure an IOX point */
IOXCC iox_cfgSetMult( uint08 *pPinCfg, size_t n );/* config multiple points */
IOXCC iox_pinGet( int08 pin, BOOL *pValue ); /* get an IOX point value */
IOXCC iox_pinSet( int08 pin, BOOL value ); /* set an IOX point value */
/****************************************************************************/
/* IO expander device driver functions. */
/* */
/* Drivers provide device-specific implementation of these functions. */
/****************************************************************************/
IOXCC ioxdd_open( IOXINITSTRUCT *pInit ); /* open an IOX device driver */
IOXCC ioxdd_configPin( uint08 pinCfg ); /* configure pin */
IOXCC ioxdd_drivePin( int08 pin, BOOL state ); /* drive output pin */
IOXCC ioxdd_readPin( int08 pin, BOOL *state ); /* read input pin */
IOXTYPE ioxdd_type( void ); /* return device type */
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -