📄 xsicp.h
字号:
/******************************************************************************
**
** COPYRIGHT (C) 2000, 2001 Intel Corporation.
**
** This software as well as the software described in it is furnished under
** license and may only be used or copied in accordance with the terms of the
** license. The information in this file is furnished for informational use
** only, is subject to change without notice, and should not be construed as
** a commitment by Intel Corporation. Intel Corporation assumes no
** responsibility or liability for any errors or inaccuracies that may appear
** in this document or any software that may be provided in association with
** this document.
** Except as permitted by such license, no part of this document may be
** reproduced, stored in a retrieval system, or transmitted in any form or by
** any means without the express written consent of Intel Corporation.
**
** FILENAME: xsicp.h
**
** PURPOSE: This file defines types and masks to be used with
** Infrared Communications Port (ICP) control registers.
**
** LAST MODIFIED: 02/21/01
** EAS VERSION : 2.0
******************************************************************************/
#ifndef _xsicp_h
#define _xsicp_h
/*
************************************************************************************
* CONSTANTS
************************************************************************************
*/
#ifdef ICP_GLOBALS
#define EXTRN
#else
#define EXTRN extern
#endif
// Masks for ICP Registers
// Infrared Comm Port Control Register 0 (ICCR0) definitions
#define ICP_ICCR0_ITR ( 0x1 << 0 ) // ICP unit enabled
#define ICP_ICCR0_LBM ( 0x1 << 1 ) // This selects loopback mode of operation
#define ICP_ICCR0_TUS ( 0x1 << 2 ) // bit 2 slects FIFO underrun response
#define ICP_ICCR0_TXE ( 0x1 << 3 ) // bit 3 enables HSSP transmit logic
#define ICP_ICCR0_RXE ( 0x1 << 4 ) // bit 4 enables HSSP receive logic
#define ICP_ICCR0_RIE ( 0x1 << 5 ) // bit 5 disables/enables Rx FIFO interrupt
#define ICP_ICCR0_TIE ( 0x1 << 6 ) // bit 6 disables/enables Tx FIFO interrupt
#define ICP_ICCR0_AME ( 0x1 << 7 ) // bit 7 disables/enables receiver address match function
// Infrared Comm Port Control Register 1 (ICCR1) definitions
#define ICP_ICCR1_MASK ( 0xFF << 0 )// Use to mask reserved bits to zero when reading and writing ICCR1.
// Infrared Comm Port Control Register 2 (ICCR2) definitions
#define ICP_ICCR2_TRIG_SHIFT 0 // These 2 bits control the FIFO trigger level
// Configure TRIG field so that service request is issued when:
#define ICP_ICCR2_TRIG_8BYTES ( 0x0 << ICP_ICCR2_TRIG_SHIFT ) // >=8 bytes
#define ICP_ICCR2_TRIG_16BYTES ( 0x1 << ICP_ICCR2_TRIG_SHIFT ) // >=16 bytes
#define ICP_ICCR2_TRIG_32BYTES ( 0x2 << ICP_ICCR2_TRIG_SHIFT ) // >=32 bytes
#define ICP_ICCR2_TXP ( 0x1 << 2 ) // Data output from ICP to Tx pin is not inverted
#define ICP_ICCR2_RXP ( 0x1 << 3 ) // Data input from Tx pin to ICP is not inverted
// Infrared Comm Port Data Register (ICDR) definitions
#define ICP_ICDR_MASK 0xFF // Use to mask bits 8-31 to zero
// Infrared Comm Port Status Register 0 (ICSR0) definitions
#define ICP_ICSR0_EIF ( 0x1 << 0 ) // End/Error in FIFO
#define ICP_ICSR0_TUR ( 0x1 << 1 ) // Transmit FIFO underrun
#define ICP_ICSR0_RAB ( 0x1 << 2 ) // Receiver abort detected
#define ICP_ICSR0_TFS ( 0x1 << 3 ) // Transmit FIFO service request
#define ICP_ICSR0_RFS ( 0x1 << 4 ) // Receiver FIFO service request
#define ICP_ICSR0_FRE ( 0x1 << 5 ) // Framing error
// Infrared Comm Port Status Register 1 (ICSR1) definitions
// All bits in register ICSR1 are READ-ONLY
#define ICP_ICSR1_RSY ( 0x1 << 0 ) // Indicates IR is in sync
#define ICP_ICSR1_TBY ( 0x1 << 1 ) // Transmitter is transmitting a frame
#define ICP_ICSR1_RNE ( 0x1 << 2 ) // Rx FIFO is not empty
#define ICP_ICSR1_TNF ( 0x1 << 3 ) // Tx FIFO is not full
#define ICP_ICSR1_EOF ( 0x1 << 4 ) // Value at bottom of RX FIFO is last byte
#define ICP_ICSR1_CRE ( 0x1 << 5 ) // CRC error occurred
#define ICP_ICSR1_ROR ( 0x1 << 6 ) // Rx FIFO overrun occurred
//ICP Base register
#define ICP_REGS_BASE 0x40800000
#define ICP_MATCH_ALL 0xff // This is used to automatically generate match
// of all incoming frames
#define ICP_RETRY_LOOP 1000
#define NUM_BUF_DEFAULT_ICP 2
#define BUFF_SIZE_DEFAULT_ICP 64
#define XFER_LEN_DEFAULT_ICP 128
#define ICP_ICSR0_STICKY (ICP_ICSR0_TUR | ICP_ICSR0_RAB | ICP_ICSR0_FRE)
#define ICP_ICSR1_STATUS (ICP_ICSR1_EOF | ICP_ICSR1_CRE | ICP_ICSR1_ROR)
// Error sub-location codes for ERR_L_XSUDC location code
#define ERR_S_XSICP_HWSETUP 0x01 // XsIcpHWSetup
#define ERR_S_XSICP_INT_HANDLER 0x02 // Register Interrupt Handler
#define ERR_S_XSICP_TRANSMIT 0x03 // Transmit function
#define ERR_S_XSICP_RECEIVE 0x04 // Receive function
#define ERR_S_XSICP_STATIC_LOOPBACK 0x05 // Static loopback function
#define ERR_S_XSICP_INV_DEV 0x06 // SW Init
// Error sub-location codes used by the tests
#define ERR_TS_XSICP_LOOPSINGLE 0x80 // IcpLoopbackSingle
#define ERR_TS_XSICP_LOOPSTATIC 0x81 // PostIcpStaticLoop
/* regsP->
************************************************************************************
* DATA TYPES
************************************************************************************
*/
// ICP Registers structure
typedef struct IcpRegsS
{
VUINT32 ICCR0;
VUINT32 ICCR1;
VUINT32 ICCR2;
VUINT32 ICDR;
VUINT32 reserved1;
VUINT32 ICSR0;
VUINT32 ICSR1;
} IcpRegsT;
// ICP configuration structures
// This structure is used by the hardware setup function
// to configure ICP
typedef struct IcpCfgS
{
INT loopback; // The loopback mode is enabled, if this is set to one
INT function; // Selects Rx or Tx operation
INT actionTxFIFOUnderrun; // Abort on Tx FIFO underrun, if this is set to one
INT RxIntEnable; // Receive FIFO interrupt enabled, if this is set to one
INT TxIntEnable; // Transmit FIFO interrupt enabled, if this is set to one
INT enableAddressMatch; // Address match enabled, if this is set to one
INT addressMatchValue; // Address match value (0-255)
INT RxFIFOTrgLevel; // Rx FIFO trigger level: 0 - 8 bytes, 1 - 16 bytes, 2 - 32 bytes
INT TxPinPolarity; // Tx pin polarity is inverted, if this is set to zero
INT RxPinPolarity; // Rx pin polarity is inverted, if this is set to zero
} IcpCfgT;
// DMA configuration structure
// Used to configure DMA to service ICP
typedef struct IcpDmaCfgS {
UINT descNum; // Number of the descriptors in the chain
UINT bufferSize; // buffer size for each of the descriptors, bytes
UINT xferLength; // Total length of the transfer, bytes
UINT sourceName; // Name of the source (see xsdma.h)
UINT targetName; // Name of the target (see xsdma.h)
UINT priority; // Channel's priority
} IcpDmaCfgT;
typedef enum IcpLoopE
{
IcpLoopbackOff,
IcpLoopbackOn
} IcpLoopT;
typedef enum IcpFunctionE
{
IcpRxOperation,
IcpTxOperation
} IcpFunctionT;
typedef enum IcpTxFIFOUnderunE
{
IcpTxFIFOUnderunNoInt,
IcpTxFIFOUnderunInt
} IcpTxFIFOUnderunT;
typedef enum IcpFIFOIntE
{
IcpFIFOIntDisabled,
IcpFIFOIntEnabled
} IcpFIFOIntT;
typedef enum IcpAddressMatchE
{
IcpAddressMatchDisabled,
IcpAddressMatchEnabled
} IcpAddressMatchT;
typedef enum IcpRxFIFOTrgLevelE
{
IcpRxFIFOTrgLevel8,
IcpRxFIFOTrgLevel16,
IcpRxFIFOTrgLevel32
} IcpRxFIFOTrgLevelT;
typedef enum IcpPinPolarityE
{
IcpPinPolarityInvert,
IcpPinPolarityNonInvert
} IcpPinPolarityT;
typedef enum IcpDmaServiceE
{
IcpDmaNotUsed,
IcpUseDma
} IcpDmaServiceT;
typedef enum IcpStatusReg0BitsE
{
IcpFifoErr,
IcpTxFifoUnderRun,
IcpRxAbort,
IcpTxFifoServReq,
IcpRxFifoServReq,
IcpFramingError
} IcpStatusReg0BitsT;
typedef enum IcpStatusReg1BitsE
{
IcpRecvSynchBit,
IcpTxBusy,
IcpRxNotEmpty,
IcpTxNotFull,
IcpEndFrame,
IcpCrcError,
IcpRxOverrun
} IcpStatusReg1BitsT;
// DMA Interrupt status structure
typedef struct IcpDmaStatusS {
INT busErrorIntCount;
INT endIntCount;
INT startIntCount;
INT stopIntCount;
} IcpDmaStatusT;
// Interrupt status structure
typedef struct IcpIntStatusS {
INT endErrorIntCount;
INT txUnderunIntCount;
INT rxAbortIntCount;
INT frameErrorIntCount;
INT trailingBytesCount;
} IcpIntStatusT;
// ICP interface
typedef UINT32 (*IcpSetupT) (void * ctxP);
typedef INT (*IcpCleanupT) (void * ctxP);
typedef INT (*IcpTransmitT) (void * ctxP, CHAR *buf, INT len, void *param);
typedef INT (*IcpReceiveT) (void * ctxP, CHAR *buf, INT len, void *param);
typedef INT (*IcpLoopbackT) (void * ctxP, INT data);
typedef INT (*IcpWriteT) (void * ctxP, CHAR *buf, INT len);
typedef INT (*IcpReadT) (void * ctxP, CHAR *buf, INT len);
typedef INT (*IcpClearRxT) (void * ctxP);
typedef INT (*IcpClearTxT) (void * ctxP);
typedef INT (*IcpReadBitStatRegT) (void * ctxP, INT bit);
typedef INT (*IcpReadStatRegT) (void * ctxP);
typedef void (*IcpDmaIntHandlerT) (void *, UINT32);
typedef void (*IcpIntHandlerT) (void *);
// ICP Context Structure
typedef struct IcpContextS {
IcpRegsT * regsP; // Pointer to ICP's register base
IcpCfgT * cfgP; // Pointer to ICP's confiquration structure
UINT32 loggedError; // Used to report tests and drivers errors
IcpDmaStatusT * dmaTxIntStatusP; // Pointer to DMA Tx Interrupt status structure
IcpDmaStatusT * dmaRxIntStatusP; // Pointer to DMA Rx Interrupt status structure
IcpIntStatusT * intStatusP; // Pointer to the Interrupt status structure
UCHAR trailingBytesBuffer[32]; // Trailing bytes buffer is used as temp. storage for trailing bytes
INT dmaRxChannel; // DMA channel used to transfer data from ICP to memory
INT dmaTxChannel; // DMA channel used to transfer data from memory to ICP
INT xferTxComplete; // Used by the dma interrupt handler to inform the test about Tx xfer completion
INT xferRxComplete; // Used by the dma interrupt handler to inform the test about Rx xfer completion
IcpDmaCfgT * dmaTxCfgP; // Pointer to DMA Tx configuration structure
IcpDmaCfgT * dmaRxCfgP; // Pointer to DMA Rx configuration structure
IcpSetupT setupIcpFnP; // Pointer to ICP's hardware setup function
IcpCleanupT shutdownIcpFnP; // Pointer to ICP's cleanup function
IcpLoopbackT loopbackIcpFnP; // Pointer to ICP's loopback function
IcpWriteT writeIcpFnP; // Pointer to ICP's write function
IcpReadT readIcpFnP; // Pointer to ICP's read function
IcpReadStatRegT readStatusReg0IcpFnP; // Pointer to ICP's read status register function
IcpReadBitStatRegT readBitStatusReg0IcpFnP; // Pointer to ICP's read bit status register function
IcpReadStatRegT readStatusReg1IcpFnP; // Pointer to ICP's read status register function
IcpReadBitStatRegT readBitStatusReg1IcpFnP; // Pointer to ICP's read bit status register function
IcpClearTxT clearTxIcpFnP; // Pointer to ICP's clear Tx. FIFO function
IcpClearRxT clearRxIcpFnP; // Pointer to ICP's clear Rx. FIFO function
IcpDmaIntHandlerT intHandlerDmaTxFnP; // Pointer to ICP's DMA Tx int. handler
IcpDmaIntHandlerT intHandlerDmaRxFnP; // Pointer to ICP's DMA Rx int. handler
IcpIntHandlerT intHandlerIcpFnP; // Pointer to ICP's interrupt handler
} IcpContextT;
/*
************************************************************************************
* GLOBAL VARIABLES
************************************************************************************
*/
EXTRN IcpContextT FastInfraredCommPort;
/*
************************************************************************************
* FUNCTION PROTOTYPES
************************************************************************************
*/
void XsIcpSWInit (void);
#undef EXTRN
#endif /* _xsicp_h */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -