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

📄 csl_uarthwsetupraw.c

📁 TI达芬奇dm644x各硬件模块测试代码
💻 C
字号:
/*  ============================================================================
 *   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_uartHwSetupRaw.c
 *
 *    @brief File for functional layer of CSL API @a CSL_uartHwSetupRaw()
 *
 *  Path: \\(CSLPATH)\\ipmodules\\uart\\src
 *
 *  Description
 *    - The @a CSL_uartHwSetupRaw() function definition & it's associated functions
 *
 */
 
/* =============================================================================
 *  Revision History
 *  ===============
 *  08-Sep-2004 brn File Created.
 *  11-Oct_2004 brn File updated with the review comments
 * =============================================================================
 */

#include <csl_uart.h>

/** ============================================================================
 *   @n@b CSL_uartHwSetupRaw
 *
 *   @b Description
 *   @n This function initializes the device registers with the register-values
 *      provided through the config data structure.  
 *
 *   @b Arguments
 *   @verbatim
            hUart            Handle to the UART instance
            
            config          Pointer to the config structure containing the
                            device register values
     @endverbatim
 *
 *   <b> Return Value </b>  CSL_Status
 *   @li                    CSL_SOK             - Configuration successful
 *   @li                    CSL_ESYS_BADHANDLE  - Invalid handle
 *   @li                    CSL_ESYS_INVPARAMS  - Configuration structure
 *                                                pointer is not properly
 *                                                 initialized
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  The registers of the specified UART instance will be setup
 *       according to the values passed through the config structure
 *
 *   @b Modifies
 *   @n Hardware registers of the specified UART instance
 *
 *   @b Example
 *   @verbatim
        CSL_UartHandle           hUart;
        CSL_UartConfig           config = CSL_UART_CONFIG_DEFAULTS;
        CSL_Status               status;

        ...
        
        status = CSL_uartHwSetupRaw (hUart, &config);
        
        ...
            
     @endverbatim
 * ===========================================================================
 */
#pragma CODE_SECTION (CSL_uartHwSetupRaw, ".text:csl_section:uart");
CSL_Status  CSL_uartHwSetupRaw (
    CSL_UartHandle        hUart,
    CSL_UartConfig        *config
)
{
    if (hUart == NULL) 
        return CSL_ESYS_BADHANDLE;
        
    if (config == NULL )   
        return CSL_ESYS_INVPARAMS;
     
    /* UART transmitter holding register */
    hUart->regs->THR = config->THR;
    
    /* UART interrupt enable register */
    hUart->regs->IER = config->IER;
    
    /* UART fifo control register */
    hUart->regs->FCR = config->FCR;
    
    /* UART Line control register */
    hUart->regs->LCR = config->LCR;
    
    /* UART Modem control register */
    hUart->regs->MCR = config->MCR;
    
    /* UART scratch register */
    hUart->regs->SCR = config->SCR;
    
    /* To access DLL or DLH Div_Latch bit of LCR has to be set */
    CSL_FINSR(hUart->regs->LCR, 7, 7, 1); 
    /* UART divisor latch register (low) */
    hUart->regs->DLL = config->DLL;
    
    /* UART divisor latch register (High) */
    hUart->regs->DLH = config->DLH;
    
    /* Disable Div_Latch bit of LCR */
    CSL_FINSR(hUart->regs->LCR, 7, 7, 0);
    
    /* UART power management and emulation register */
    hUart->regs->PWREMU_MGMT = config->PWREMU_MGMT;
    
    return CSL_SOK;
}



⌨️ 快捷键说明

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