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

📄 csl_uarthwcontrol.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_uartHwControl.c
 *  
 *  @brief    File for functional layer of CSL API @a CSL_uartHwControl()
 *
 *  Path: \\(CSLPATH)\\ipmodules\\uart\\src
 *
 *  Description
 *    - The @a CSL_uartHwControl() function definition & it's associated
 *      functions
 *  @date 30 April, 2004
 *  @author Pratheesh Gangadhar
 */
 
/* =============================================================================
 *  Revision History
 *  ===============
 *  08-Sep-2004 brn Updated for the new CSL architecture
 *  11-Oct-2004 brn Updated with the code review comments.
 *  29_Jun-2005 brn In CSL_uartRead function the call made call-by-reference 
                    with the existing call-by-value
 * =============================================================================
*/

#include <csl_uart.h>
#include <csl_uartAux.h>

/** ============================================================================
 *   @n@b   CSL_uartHwControl
 *
 *   @b Description
 *   @n Control operations for the UART.  For a particular control operation, the
 *  pointer to the corresponding data type needs to be passed as argument 
 *  HwControl function Call. All the arguments (Structure elements included) 
 *  passed to  the HwControl function are inputs. For the list of commands 
 *  supported and argument type that can be @a void* casted & passed with a 
 *  particular command refer to @a CSL_UartHwControlCmd.
 *
 *
 *   @b Arguments
 *   @verbatim
            hUart        Handle to the UART instance

            cmd          Operation to be performed on the UART

            arg          Argument specific to the command

     @endverbatim
 *
 *   <b> Return Value </b>  CSL_Status
 *   @li                    CSL_SOK            - Command execution successful.
 *   @li                    CSL_ESYS_BADHANDLE - Invalid handle
 *   @li                    CSL_ESYS_INVCMD    - Invalid command
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  Registers of the UART instance are configured according to the command
 *       and the command arguments. The command determines which registers are
 *       modified.
 *
 *   @b Modifies
 *   @n Registers determined by the command
 *
 *  <b> Usage Constraints: 
 *  Both @a CSL_uartInit() and @a CSL_uartOpen() must be called successfully
 *  in that order before @a CSL_uartHwControl() can be called. For the
 *  argument type that can be @a void* casted & passed with a particular command
 *  refer to @a CSL_UartHwControlCmd
 *
 * @b Example:
 * @verbatim
       CSL_UartHandle hUart;
       CSL_Status status;
       ...
       status = CSL_uartHwControl(hUart,
                                  CSL_UART_CMD_START,
                                  &command);
   @endverbatim
 *
 *  @return returns the status of the operation (see @a CSL_Status)
 * ============================================================================
 */
#pragma CODE_SECTION (CSL_uartHwControl, ".text:csl_section:uart");
CSL_Status CSL_uartHwControl (
    CSL_UartHandle        hUart,
    CSL_UartHwControlCmd  cmd,
    void                  *arg 
)
{
    CSL_Status status = CSL_SOK;
   /* Uint8  *tmpbuff;
    Uint32 numBytes, tmpstat;
    Uint16 divisor; 
    CSL_UartRegsOvly uartRegs = hUart->regs;*/
    
    /* Pratheesh G 04/29/2004
     * I prefer local copies here for performance
     * Need to investigate - stack overhead  
     */
     
    /*CSL_UartBaudConfig configBaud;
    CSL_UartLineConfig configLine;
    CSL_UartFifoConfig configFifo;
    CSL_UartBufferDescriptor descriptor;*/
    
    if (hUart == NULL) {
        return CSL_ESYS_BADHANDLE;
    } 
    
    switch (cmd) {
        case CSL_UART_CMD_WRITE: 
            CSL_uartWrite (hUart, (CSL_UartBufferDescriptor *) arg);
            break;
            
        case CSL_UART_CMD_READ: 
            CSL_uartRead (hUart, (CSL_UartBufferDescriptor *) arg);
            break;  
          
        case CSL_UART_CMD_WRITEBYTE:
            CSL_uartWriteByte (hUart, * (Uint8 *) arg);
            break;
            
        case CSL_UART_CMD_READBYTE:
            *(Uint8 *)arg = CLS_uartReadByte (hUart);
            break;   
        
        case CSL_UART_CMD_INTR_DISABLE:
        case CSL_UART_CMD_INTR_ENABLE:
            CSL_uartIntrEnable (hUart, *(CSL_BitMask32 *)arg, cmd);   
            break;   
            
        case CSL_UART_CMD_RTS_HIGH:
            CSL_uartRtsHigh (hUart);
            break;   
            
        case CSL_UART_CMD_RTS_LOW:
            CSL_uartRtsLow (hUart);
            break;
            
        case CSL_UART_CMD_DTR_HIGH:
            CSL_uartDtrHigh (hUart);
            break;   
            
        case CSL_UART_CMD_DTR_LOW:
            CSL_uartDtrLow (hUart);
            break;
            
        case CSL_UART_CMD_OUT1_HIGH:
            CSL_uartOut1High (hUart);  
            break;          
            
        case CSL_UART_CMD_OUT1_LOW:
            CSL_uartOut1Low (hUart);
            break;            
            
        case CSL_UART_CMD_OUT2_HIGH:
            CSL_uartOut2High (hUart);  
            break;            
            
        case CSL_UART_CMD_OUT2_LOW:
            CSL_uartOut2Low (hUart);
            break; 
            
        case CSL_UART_CMD_FIFO_DISABLE:
            CSL_uartFifoDisable(hUart);
            break;          
            
        case CSL_UART_CMD_FIFO_ENABLE:
            CSL_uartFifoEnable(hUart);
            break;            
            
        case CSL_UART_CMD_CONFIG_FIFO:
            CSL_uartConfigFifo (hUart, *(CSL_UartFifoConfig*) arg);
            break;            
            
        case CSL_UART_CMD_RESET_TXFIFO:
            CSL_uartResetTxFifo (hUart);
            break;
            
        case CSL_UART_CMD_RESET_RXFIFO:
            CSL_uartResetRxFifo (hUart); 
            break;   
            
        case CSL_UART_CMD_BREAK_ENABLE:
            CSL_uartBreakEnable (hUart); 
            break;            
            
        case CSL_UART_CMD_BREAK_DISABLE:
            CSL_uartBreakDisable (hUart);
            break;
            
        case CSL_UART_CMD_CONFIG_BAUDRATE:
            CSL_uartConfigBaudRate (hUart, *(CSL_UartBaudConfig*)arg);
            break;          
            
        case CSL_UART_CMD_CONFIG_LINE:
            CSL_uartConfigLine (hUart, *(CSL_UartLineConfig*)arg);
            break;                
            
        case CSL_UART_CMD_CONFIG_AUTOFLOW:
            switch (*(CSL_UartAutoflowCtrl*)arg) {
                case CSL_UART_AUTOFLOW_DISABLE:
                    CSL_uartAutoflowDisable (hUart);  
                    break;
                    
                case CSL_UART_AUTO_CTS_RTS:  
                     CSL_uartAutoCtsRts (hUart);
                    break;
                    
                case CSL_UART_AUTO_CTS:  
                     CSL_uartAutoCts (hUart);
                    break;
            }                                 
            break;  
                    
        case CSL_UART_CMD_LOOPBACK_ENABLE:
            CSL_uartLoopbackEnable (hUart);   
            break;   
            
        case CSL_UART_CMD_LOOPBACK_DISABLE:
            CSL_uartLoopbackDisable (hUart);
            break;
            
        case CSL_UART_CMD_STOP:
            CSL_uartStop (hUart);
            break;
            
        case CSL_UART_CMD_RUN_FREE:    
            CSL_uartRunFree (hUart);
            break;     
            
        case CSL_UART_CMD_ENABLE:
            CSL_uartEnable (hUart);
            break;
            
        case CSL_UART_CMD_RESET:
            CSL_uartReset (hUart);
            break;
            
        default:
            status = CSL_ESYS_INVCMD;
            break;
    }
    
    return status;
}

⌨️ 快捷键说明

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