⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 csl_utopia2.h

📁 Dm6455 driver,magbe useful to you!
💻 H
📖 第 1 页 / 共 2 页
字号:
/*  ============================================================================
 *   Copyright (c) Texas Instruments Inc 2002, 2003, 2004, 2005
 *
 *   Use of this software is controlled by the terms and conditions found
 *   in the license agreement under which this software has been supplied.
 *  ============================================================================
 */
/** ============================================================================
 *   @file    csl_utopia2.h
 *
 *   @path    $(CSLPATH)\inc
 *
 *   @desc    This files contains the macros and inline function for UTOPIA2.
 *
 */

/*  ============================================================================
 *  Revision History
 *  ================
 *  15-Feb-2006 ds     - Added #undef  IDECL and #undef  IDEF
 *
 *  ============================================================================
 */

#ifndef _CSL_UTOPIA2_H_
#define _CSL_UTOPIA2_H_

#include <cslr_utopia2.h>
#include <soc.h>

/******************************************************************************\
* scope and inline control macros
\******************************************************************************/
#ifdef __cplusplus
#define CSLAPI extern "C" far 
#else
#define CSLAPI extern far 
#endif

#undef  IDECL
#undef  IDEF

#define IDECL static inline
#define IDEF  static inline

/******************************************************************************\
* global macro declarations
\******************************************************************************/

/* utopia2 interrupt numbers */
/** Interrupt for Transmit queue */
#define UTOPIA2_INT_XQ     0
/** Interrupt for Receive queue */
#define UTOPIA2_INT_RQ     16

/* utopia2 error interrupt numbers */
/** Receive queue stall interrupt enable bit. */
#define UTOPIA2_ERR_RQS    0
/** Receive clock failed interrupt enable bit. */
#define UTOPIA2_ERR_RCF    1
/** Receive clock present interrupt enable bit. */
#define UTOPIA2_ERR_RCP    2
/** Transmit queue stall interrupt enable bit. */
#define UTOPIA2_ERR_XQS    16
/** Transmit clock failed interrupt enable bit. */
#define UTOPIA2_ERR_XCF    17
/** Transmit clock present interrupt enable bit. */
#define UTOPIA2_ERR_XCP    18

/** Base address of the UTOPIA2 receive queue */
#define UTOPIA2_RCVQ_ADDR  CSL_UTOPIA2_RX_EDMA_REGS 
/** Base address of the UTOPIA2 transmit queue */
#define UTOPIA2_XMTQ_ADDR  CSL_UTOPIA2_TX_EDMA_REGS 

/** Default value of UCR */
#define UTOPIA2_UCR_DEFAULT    (0x00000000u)
/** Default value of CDR */
#define UTOPIA2_CDR_DEFAULT    (0x00FF00FFu)

/******************************************************************************\
* global typedef declarations
\******************************************************************************/

/* device configuration structure */
/**
 * @brief   The Config structure
 *
 * Used to configure the UTOPIA2 using utopia2_config(ucr,cdr);
 */
typedef struct {
    /** UTOPIA2 Control Register */
    Uint32 ucr;
    /** Clock Detect Register of UTOPIA2 */
    Uint32 cdr;
} UTOPIA2_Config;

/******************************************************************************\
* global variable declarations
\******************************************************************************/
extern CSL_Utopia2Regs *utopia2Regs;

/******************************************************************************\
* global function declarations
\******************************************************************************/
CSLAPI void UTOPIA2_reset();

/******************************************************************************\
* inline function definitions
\******************************************************************************/
/** ============================================================================
 *   @n@b UTOPIA2_getXmtAddr
 *
 *   @b Description
 *   @n This function is to get the transmit address of UTOPIA2.  This address 
 *      is needed to write to the Transmit Port. 
 *
 *   @b Arguments
 *   @n None
 *
 *   <b> Return Value </b>  
 *   @li                        val - address of transmit queue
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  None
 *
 *   @b Modifies
 *   @n  None
 *
 *   @b Example
 *   @verbatim
            Uint32 utopXmtAddr;
            utopXmtAddr = UTOPIA2_getXmtAddr();
     @endverbatim
 * =============================================================================
 */
IDEF 
Uint32 UTOPIA2_getXmtAddr (
    void
)
{
    return (Uint32)(UTOPIA2_XMTQ_ADDR);
}

/** ============================================================================
 *   @n@b UTOPIA2_getRcvAddr
 *
 *   @b Description
 *   @n This function is to get the receive address of UTOPIA2.  This address 
 *      is required to read from the Receiver Port.
 *
 *   @b Arguments
 *   @n None
 *
 *   <b> Return Value </b>  
 *   @li                        val - address of receive queue
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  None
 *
 *   @b Modifies
 *   @n  None
 *
 *   @b Example
 *   @verbatim
            Uint32 utopRcvAddr;
            utopRcvAddr = UTOPIA2_getRcvAddr();
     @endverbatim
 * =============================================================================
 */
IDEF 
Uint32 UTOPIA2_getRcvAddr (
    void
)
{
    return (Uint32)(UTOPIA2_RCVQ_ADDR);
}

/** ============================================================================
 *   @n@b UTOPIA2_getEventId
 *
 *   @b Description
 *   @n This function is to get the event Id associated to the 
 *      UTOPIA2 CPU-interrupt Id.
 *
 *   @b Arguments
 *   @n  None
 *
 *   <b> Return Value </b>  
 *   @li                        val - Event Id of UTOPIA2
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  None
 *
 *   @b Modifies
 *   @n  None
 *
 *   @b Example
 *   @verbatim
            Uint32 utopEventId;
            utopEventId = UTOPIA2_getEventId();
     @endverbatim
 * =============================================================================
 */
IDEF 
Uint32 UTOPIA2_getEventId (
    void
)
{
    return (CSL_INTC_EVENTID_UINT);
}

/** ============================================================================
 *   @n@b UTOPIA2_read
 *
 *   @b Description
 *   @n Reads data from the receive queue of UTOPIA2.
 *
 *   @b Arguments
 *   @n  None
 *
 *   <b> Return Value </b>  
 *   @li                        val - Data from the receive queue.
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  None
 *
 *   @b Modifies
 *   @n  None
 *
 *   @b Example
 *   @verbatim
            Uint32 utopRxData;
            utopRxData = UTOPIA2_read();
     @endverbatim
 * =============================================================================
 */
IDEF 
Uint32 UTOPIA2_read (
    void
)
{
    return (*(volatile Uint32*)(UTOPIA2_RCVQ_ADDR));
}

/** ============================================================================
 *   @n@b UTOPIA2_write
 *
 *   @b Description
 *   @n Writes data into the transmit queue of UTOPIA2.
 *
 *   @b Arguments
 *   @verbatim
        val - Value to be written into transmit queue
        

     @endverbatim
 *
 *
 *   <b> Return Value </b>  
 *   @n  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  Value passed is written at transmit address of UTOPIA2 i.e., 
 *       UTOPIA2_XMTQ_ADDR.
 *
 *   @b Modifies
 *   @n  None
 *
 *   @b Example
 *   @verbatim
            Uint32 utopTxData = 0x1111FFFF;
            UTOPIA2_write(utopTxData);
     @endverbatim
 * =============================================================================
 */
IDEF 
void UTOPIA2_write (
    Uint32    val
)
{
    (*(volatile Uint32*)(UTOPIA2_XMTQ_ADDR)) = val;
}

/** ============================================================================
 *   @n@b UTOPIA2_enableXmt
 *
 *   @b Description
 *   @n Enables transmitter port
 *
 *   @b Arguments
 *   @n None
 *
 *   <b> Return Value </b>  
 *   @n  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  None
 *
 *   @b Modifies
 *   @n Modifies the UXEN bit of UCR register
 *
 *   @b Example
 *   @verbatim
             // Configure UTOPIA2
             UTOPIA2_configArgs(0x00040004, // ucr
                             0x00FF00FF // cdr);
             .....
             .....
             //Enables Transmitter port
             UTOPIA2_enableXmt();
     @endverbatim
 * =============================================================================
 */
IDEF 
void UTOPIA2_enableXmt (
    void
)
{
    CSL_FINST(utopia2Regs->UCR, UTOPIA2_UCR_UXEN, TX_PORT_ENABLE);
}

/** ============================================================================
 *   @n@b UTOPIA2_enableRcv
 *
 *   @b Description
 *   @n Enables the reciever port
 *
 *   @b Arguments
 *   @n  None
 *
 *   <b> Return Value </b>  
 *   @n  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  None
 *
 *   @b Modifies
 *   @n  Modifies the UREN bit of UCR register
 *
 *   @b Example
 *   @verbatim
             // Configure UTOPIA2
             UTOPIA2_configArgs(0x00040004, // ucr
                             0x00FF00FF // cdr);
             .....
             .....
             //Enables Receiver port
             UTOPIA2_enableRcv();
     @endverbatim
 * =============================================================================
 */
IDEF 
void UTOPIA2_enableRcv (
    void
)
{
    CSL_FINST(utopia2Regs->UCR, UTOPIA2_UCR_UREN, RX_PORT_ENABLE);
}

/** ============================================================================
 *   @n@b UTOPIA2_errDisable
 *
 *   @b Description
 *   @n Disables the error interrupt event.
 *
 *   @b Arguments
 *   @verbatim
             errNum - Error condition ID 

             The following are the possible errors from EIPR
                 - UTOPIA2_ERR_RQS
                 - UTOPIA2_ERR_RCF
                 - UTOPIA2_ERR_RCP
                 - UTOPIA2_ERR_XQS

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -