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

📄 csl_utopia2.h

📁 Dm6455 driver,magbe useful to you!
💻 H
📖 第 1 页 / 共 2 页
字号:
                 - UTOPIA2_ERR_XCF
                 - UTOPIA2_ERR_XCP
        
     @endverbatim
 *
 *   <b> Return Value </b>  
 *   @n  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  None
 *
 *   @b Modifies
 *   @n  Clears the transmit clock fail bit of EIER register.
 *
 *   @b Example
 *   @verbatim
             // disables the transmit clock fail error bit.
             UTOPIA2_errDisable(UTOPIA2_ERR_XCF);
     @endverbatim
 * =============================================================================
 */
IDEF 
void UTOPIA2_errDisable (
    Uint32    errNum
)
{
    (utopia2Regs->EIER) = ((utopia2Regs->EIER) & (~(1<<errNum)));
}

/** ============================================================================
 *   @n@b UTOPIA2_errEnable
 *
 *   @b Description
 *   @n Enables the bit of given error condition ID of EIPR.
 *
 *   @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
                 - UTOPIA2_ERR_XCF
                 - UTOPIA2_ERR_XCP
        
     @endverbatim
 *
 *   <b> Return Value </b>  
 *   @n  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  None
 *
 *   @b Modifies
 *   @n  Sets the transmit clock fail bit of EIER register
 *
 *   @b Example
 *   @verbatim
             // Enables the transmit clock fail error bit.
             UTOPIA2_errEnable(UTOPIA2_ERR_XCF);
     @endverbatim
 * =============================================================================
 */
IDEF 
void UTOPIA2_errEnable (
    Uint32    errNum
)
{
    (utopia2Regs->EIER) = ((utopia2Regs->EIER) | (1<<errNum));
}

/** ============================================================================
 *   @n@b UTOPIA2_errClear
 *
 *   @b Description
 *   @n Clears the bit of given error condition ID of EIPR.
 *
 *   @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
                 - UTOPIA2_ERR_XCF
                 - UTOPIA2_ERR_XCP
        
     @endverbatim
 *
 *   <b> Return Value </b>  
 *   @n  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  None
 *
 *   @b Modifies
 *   @n Clears the transmit clock fail bit of EIPR register
 *
 *   @b Example
 *   @verbatim
             // clears the transmit clock fail error bit.
             UTOPIA2_errClear(UTOPIA2_ERR_XCF);
     @endverbatim
 * =============================================================================
 */
IDEF 
void UTOPIA2_errClear (
    Uint32    errNum
)
{
    (utopia2Regs->EIPR) = ((utopia2Regs->EIPR) & (~(1<<errNum)));
}

/** ============================================================================
 *   @n@b UTOPIA2_errTest
 *
 *   @b Description
 *   @n Checks the error status of given error number.
 *
 *   @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
                 - UTOPIA2_ERR_XCF
                 - UTOPIA2_ERR_XCP
        
     @endverbatim
 *
 *   <b> Return Value </b>  
 *   @n  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  None
 *
 *   @b Modifies
 *   @n  None
 *
 *   @b Example
 *   @verbatim
             // checking for the transmit clock fail error bit.
             Uint32 errDetect;
             UTOPIA2_errEnable(UTOPIA2_ERR_RCF);
             errNum = UTOPIA2_errTest(UTOPIA2_ERR_RCF)
     @endverbatim
 * =============================================================================
 */
IDEF 
Uint32 UTOPIA2_errTest (
    Uint32    errNum
)
{
	return ((utopia2Regs->EIPR & (1<<errNum)) ? 1 : 0);
}

/** ============================================================================
 *   @n@b UTOPIA2_errReset
 *
 *   @b Description
 *   @n Disables and clears the error interrupt bit associated to the 
 *           given error number.
 *
 *   @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
                 - UTOPIA2_ERR_XCF
                 - UTOPIA2_ERR_XCP
        
     @endverbatim
 *
 *   <b> Return Value </b>  
 *   @n  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  None
 *
 *   @b Modifies
 *   @n Clears the specified bit of EIPR register.
 *
 *   @b Example
 *   @verbatim
             // disables & clears the transmit clock fail error bit.
             UTOPIA2_errReset(UTOPIA2_ERR_XCF);
     @endverbatim
 * =============================================================================
 */
IDEF 
void UTOPIA2_errReset (
    Uint32    errNum
)
{
    UTOPIA2_errDisable(errNum);
    UTOPIA2_errClear(errNum);
}

/** ============================================================================
 *   @n@b UTOPIA2_config
 *
 *   @b Description
 *   @n Sets up configuration to use the UTOPIA2.  The values are set
 *           to the UTOPIA2 register (UCR, CDR).
 *
 *   @b Arguments
 *   @verbatim
             config - Pointer to an initialized configuration structure

     @endverbatim
 *
 *   <b> Return Value </b>  
 *   @n  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  None
 *
 *   @b Modifies
 *   @n UCR and CDR registers of UTOPIA2
 *
 *   @b Example
 *   @verbatim
             UTOPIA2_Config utopConfig = {
                                     0x00000000, // ucr 
                                     0x00FF00FF  // cdr };
             ........
             ........
             UTOPIA2_config(&utopConfig);
     @endverbatim
 * =============================================================================
 */
IDEF 
void UTOPIA2_config (
    UTOPIA2_Config    *config
)
{

    Uint32 cs;
    register int ucrVal, cdrVal;

    CSL_Utopia2Regs *base = (CSL_Utopia2Regs *) CSL_UTOPIA2_0_REGS;

    cs = _disable_interrupts();

    /* the compiler generates more efficient code if the loads */
    /* and stores are grouped together rather than intermixed  */
    ucrVal = config->ucr;
    cdrVal = config->cdr;

    base->UCR = UTOPIA2_UCR_DEFAULT;
    base->CDR = cdrVal;
    base->UCR = ucrVal; 
    /* Enable interface after everything is set up */
    _restore_interrupts(cs);
}

/** ============================================================================
 *   @n@b UTOPIA2_configArgs
 *
 *   @b Description
 *   @n Sets up the UTOPIA2 mode by writing the registers which is passed in.
 *
 *   @b Arguments
 *   @verbatim
             ucr - Utopia2 Control Register value
             cdr - Clock Detect Register value

     @endverbatim
 *
 *   <b> Return Value </b>  
 *   @n  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  None
 *
 *   @b Modifies
 *   @n UCR and CDR registers of UTOPIA2
 *
 *   @b Example
 *   @verbatim
             UTOPIA2_configArgs(0x00000000, // ucr 
                             0x00FF00FF  // cdr);
     @endverbatim
 * =============================================================================
 */
IDEF 
void UTOPIA2_configArgs (
    Uint32    ucr, 
    Uint32    cdr
)
{

    Uint32 cs;
    CSL_Utopia2Regs *base = (CSL_Utopia2Regs *) CSL_UTOPIA2_0_REGS;

    cs = _disable_interrupts();

    base->UCR = UTOPIA2_UCR_DEFAULT;
    base->CDR = cdr;
    base->UCR = ucr; 
    /* Enable interface after everything is set up */
    _restore_interrupts(cs);
}

/** ============================================================================
 *   @n@b UTOPIA2_getConfig
 *
 *   @b Description
 *   @n Reads the configuration values into the config structure.
 *
 *   @b Arguments
 *   @verbatim
             config - Pointer to a configuration structure.

     @endverbatim
 *
 *   <b> Return Value </b>  
 *   @n  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  None
 *
 *   @b Modifies
 *   @n  None
 *
 *   @b Example
 *   @verbatim
             UTOPIA2_config utopConfig;
             UTOPIA2_getConfig(&utopConfig);
     @endverbatim
 * =============================================================================
 */
IDEF 
void UTOPIA2_getConfig (
    UTOPIA2_Config    *config
)
{
    Uint32 cs;
    CSL_Utopia2Regs *base = (CSL_Utopia2Regs *) CSL_UTOPIA2_0_REGS;
    register int ucrVal, cdrVal;

    cs = _disable_interrupts();

    /* the compiler generates more efficient code if the loads */
    /* and stores are grouped together rather than intermixed  */
    ucrVal = base->UCR;
    cdrVal = base->CDR;
  
    config->ucr = ucrVal;
    config->cdr = cdrVal;

    _restore_interrupts(cs);
}

#endif /* _CSL_UTOPIA2_H_ */
/******************************************************************************\
* End of csl_utopia2.h
\******************************************************************************/

⌨️ 快捷键说明

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