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

📄 csl_uart.h

📁 TI达芬奇dm644x各硬件模块测试代码
💻 H
📖 第 1 页 / 共 3 页
字号:

/**
 *  @defgroup CSL_UART_CONTROLCMD_ENUM  Control Commands
 *  @ingroup CSL_UART_CONTROL_API
 */
/** @brief Enumeration for control commands passed to \a CSL_uartHwControl()
 *
 *  This is the set of commands that are passed to the \a CSL_uartHwControl()
 *  with an optional argument type-casted to \a void* .
 *  The arguments to be passed with each enumeration (if any) are specified
 *  next to the enumeration
 */
typedef enum {
    /**
     *  @brief Write a byte to THR
     *  @param (Uint8*)
     *  @return CSL_SOK
     */
    CSL_UART_CMD_WRITEBYTE          = 1,

    /**
     *  @brief   Read a byte from RBR if data is ready
     *  @param   (Uint8*)
     *  @return  CSL_SOK
     */
    CSL_UART_CMD_READBYTE           = 2,

    /**
     *  @brief  Write specified number of characters into TxFIFO
     *  @n The "transfernum" field acts as output parameter
     *  reporting the actual number of bytes written
     *  @param (CSL_UartBufferDescriptor*)
     *  @return CSL_SOK
     *  @a CSL_UartBufferDescriptor
     */
    CSL_UART_CMD_WRITE              = 3,

    /**
     *  @brief  Read specified number of characters from RxFIFO
     *  @n The "transfernum"  and "error" fields act as output parameters
     *  reporting the actual number of bytes read and error respectively
     *  @param (CSL_UartBufferDescriptor*)
     *  @return CSL_SOK
     *  @sa CSL_UartBufferDescriptor
     */
    CSL_UART_CMD_READ               = 4,

    /**
     *  @brief Disables interrupts specified by input bitmask
     *  @param (CSL_BitMask32*)
     *  @return CSL_SOK
     *  @sa CSL_UART_INTRSTAT_DEFINE
     */
    CSL_UART_CMD_INTR_DISABLE       = 5,

    /**
     *  @brief Enables interrupts specified by input bitmask
     *  @param (CSL_BitMask32*)
     *  @return CSL_SOK
     *  @sa CSL_UART_INTRSTAT_DEFINE
     */
    CSL_UART_CMD_INTR_ENABLE        = 6,

    /**
     *  @brief Forces RTS output high
     *  @param NONE
     *  @return CSL_SOK
     */
    CSL_UART_CMD_RTS_HIGH           = 7,

    /**
     *  @brief Forces RTS output low
     *  @param NONE
     *  @return CSL_SOK
     */
    CSL_UART_CMD_RTS_LOW            = 8,

    /**
     *  @brief Forces DTR output high
     *  @param NONE
     *  @return CSL_SOK
     */
    CSL_UART_CMD_DTR_HIGH           = 9,

    /**
     *  @brief Forces DTR output low
     *  @param NONE
     *  @return CSL_SOK
     */
    CSL_UART_CMD_DTR_LOW            = 10,

    /**
     *  @brief Forces OUT1 output high
     *  @param NONE
     *  @return CSL_SOK
     */
    CSL_UART_CMD_OUT1_HIGH          = 11,

    /**
     *  @brief Forces OUT1 output low
     *  @param NONE
     *  @return CSL_SOK
     */
    CSL_UART_CMD_OUT1_LOW           = 12,

    /**
     *  @brief Forces OUT2 output high
     *  @param NONE
     *  @return CSL_SOK
     */
    CSL_UART_CMD_OUT2_HIGH          = 13,

    /**
     *  @brief Forces OUT2 output low
     *  @param NONE
     *  @return CSL_SOK
     */
    CSL_UART_CMD_OUT2_LOW           = 14,

    /**
     *  @brief Disables FIFO mode
     *  @param NONE
     *  @return CSL_SOK
     */
    CSL_UART_CMD_FIFO_DISABLE       = 15,

    /**
     *  @brief Enables FIFO mode
     *  @param NONE
     *  @return CSL_SOK
     */
    CSL_UART_CMD_FIFO_ENABLE        = 16,

    /**
     *  @brief Configures FIFO, set triggerlevel and DMA mode
     *  @param (CSL_UartFifoConfig*)
     *  @return CSL_SOK
     *  @sa CSL_UartFifoConfig */
    CSL_UART_CMD_CONFIG_FIFO        = 17,

    /**
     *  @brief  Reset TxFIFO counters
     *  @param  NONE
     *  @return CSL_SOK
     */
    CSL_UART_CMD_RESET_TXFIFO       = 18,

    /**
     *  @brief  Reset RxFIFO counters
     *  @param  NONE
     *  @return CSL_SOK
     */
    CSL_UART_CMD_RESET_RXFIFO       = 19,

    /**
     *  @brief Disables break condition
     *  @param  NONE
     *  @return CSL_SOK
     */
    CSL_UART_CMD_BREAK_DISABLE      = 20,

    /**
     *  @brief  Enables break condition
     *  @param  NONE
     *  @return CSL_SOK
     */
    CSL_UART_CMD_BREAK_ENABLE       = 21,

    /**
     *  @brief  Configures baudrate
     *  @param  (CSL_UartBaudConfig*)
     *  @return CSL_SOK
     *  @sa CSL_UartBaudConfig
     */
    CSL_UART_CMD_CONFIG_BAUDRATE    = 22,

    /**
     *  @brief  Controls the format of the asynchronous data communication
     *  exchange
     *  @param  (CSL_UartLineConfig*)
     *  @return CSL_SOK
     *  @sa CSL_UartLineConfig
     */
    CSL_UART_CMD_CONFIG_LINE        = 23,

    /**
     *  @brief  Configures autoflow parameters
     *  @param  (CSL_UartAutoflowCtrl*)
     *  @return CSL_SOK
     *  @sa CSL_UartAutoflowCtrl
     */
    CSL_UART_CMD_CONFIG_AUTOFLOW    = 24,

    /**
     *  @brief  Disables loopback mode
     *  @param  NONE
     *  @return CSL_SOK
     */
    CSL_UART_CMD_LOOPBACK_DISABLE   = 25,

    /**
     *  @brief  Enables loopback mode
     *  @param  NONE
     *  @return CSL_SOK
     */
    CSL_UART_CMD_LOOPBACK_ENABLE    = 26,

    /**
     *  @brief the UART stop immediately if a transmission
     *  isn't in progress. If a transmission is in progress, the UART
     *  stops after completion of the one word transmission
     *  @param  NONE
     *  @return CSL_SOK
     */
    CSL_UART_CMD_STOP               = 27,

    /**
     *  @brief  UART runs free
     *  @param  NONE
     *  @return CSL_SOK
     */
    CSL_UART_CMD_RUN_FREE           = 28,

    /**
     *  @brief  Re-enables transmitter and receiver
     *  @param  NONE
     *  @return CSL_SOK
     */
    CSL_UART_CMD_ENABLE             = 30,

    /**<
     *  @brief  Resets UART module
     *  @param  NONE
     *  @return CSL_SOK */
    CSL_UART_CMD_RESET              = 31

} CSL_UartHwControlCmd;

/**
 *  @defgroup CSL_UART_QUERYCMD_ENUM Query Commands
 *  @ingroup CSL_UART_QUERY_API
 *  @{
 */

/**
 *  @brief Enumeration for queries passed to \a CSL_UartGetHwStatus()
 * This is used to get the status of different operations.The arguments
 * to be passed with each enumeration if any are specified next to
 * the enumeration
 */
typedef enum {
    /**
     *  @brief Queries Receiver Line Status
     *  @param (CSL_BitMask32*)
     *  @return CSL_SOK
     *  @sa CSL_UART_LINESTAT_DEFINE
     */
    CSL_UART_QUERY_LINESTATUS       = 1,

    /**
     *  @brief Queries Modem Status
     *  @param (CSL_BitMask32*)
     *  @return CSL_SOK
     *  @sa CSL_UART_MODEMSTAT_DEFINE
     */
    CSL_UART_QUERY_MODEMSTATUS      = 2,

    /**
     *  @brief Interrupt Enable Status
     *  @param (CSL_BitMask32*)
     *  @return CSL_SOK
     *  @sa CSL_UART_INTRSTAT_DEFINE  */
    CSL_UART_QUERY_INTRSTATUS       = 3,

    /**
     *  @brief Queries Version of UART
     *  @param (Uint8*)
     *  @return CSL_SOK
     */
    CSL_UART_QUERY_VERSION          = 4,

    /**
     *  @brief Queries Interrupt Source
     *  @param (CSL_UartIntrSource*)
     *  @return CSL_SOK
     *  @sa CSL_UartIntrSource
     */
    CSL_UART_QUERY_INTRSOURCE       = 5

} CSL_UartHwStatusQuery;
/**
@} */

/**
 *  @addtogroup CSL_UART_DATASTRUCT
 *  @{
 */

/**
 *  @brief UART buffer descriptor
 *  Used when sending/receiving data
 *  @sa CSL_UART_LINESTAT_DEFINE
 */
typedef struct {
    /** Pointer to data transfer/receive buffer */
    Uint8* buff;

    /** Number of bytes(5/6/7/8 chars) to be transferred */
    Uint32 num;

    /** Number of bytes(5/6/7/8 chars) actually transferred */
    Uint32 transfernum;

    /** ORed combination of errors i.e parity and/or break and/or
         frame Error */
    CSL_BitMask32 error ;

} CSL_UartBufferDescriptor;
/**
@} */

/**
 *  @addtogroup CSL_UART_DATASTRUCT
 @{
 */
/**
 *  @brief UART baudrate confiuration
 *  Used to configure UART baudarate clock divisor
 *  @sa CSL_UART_BAUDRATE_DEFINE
 */
typedef struct {
    /** Module Clock Frequency(Hz) */
    Uint32  moduleClock;

    /** Standard baudrate setting */
    Uint32  baudrate;

} CSL_UartBaudConfig;
/**
@} */

/**
 @addtogroup CSL_UART_DATASTRUCT
 @{
 */
/**  @brief UART line confiuration
 *
 *   Used to configure character length, stopbits and parity
 *   @sa CSL_UART_PARITY_DEFINE
 */
typedef struct {
    /** Serial character word length*/
    CSL_UartCharLen  charLen;

    /** Stop bits generated */
    CSL_UartNumStop  numStopBits;

    /** Parity control bitfield*/
    CSL_BitMask32    parityCtrl;
} CSL_UartLineConfig;
/**
@} */

/**
 *  @addtogroup CSL_UART_DATASTRUCT
 @{
 */

/**
 * @brief UART FIFO confiuration
 * Used to configure RX FIFO threshold level and DMA
 *
 */
typedef struct {
    /** Rx FIFO trigger level*/
    CSL_UartRxFifoTrigLevel  trigLevel;

    /** When set selects mode1 of DMA */
    CSL_UartDmaCtrl          dmaMode;

} CSL_UartFifoConfig;
/**
@} */


/**
 *  @addtogroup CSL_UART_DATASTRUCT
 @{
 */

/**
 *  @brief Input parameters for setting up UART
 *  @sa CSL_UART_INTRSTAT_DEFINE
 *
 */
typedef struct {
    /** UART autoflow configuration structure*/
    CSL_UartAutoflowCtrl flowControl;

    /** setup structure for UART Fifo configuration */
    CSL_UartFifoCtrl   fifoEnable;

    /** setup structure for UART Loopback mode control */
    CSL_UartLoopCtrl   loopEnable;

    /** setup structure for UART Emulation modes control */
    CSL_UartEmuCtrl    emuConfig;

    /** To Enable interrupts of UART */
    CSL_BitMask32      interruptEnable;

    /** setup structure for UART baudarate clock divisor */
    CSL_UartBaudConfig setupBaud;

    /** setup structure for UART character length, stopbits and parity */
    CSL_UartLineConfig setupLine;

    /** setup structure for UART RX FIFO threshold level and DMA */
    CSL_UartFifoConfig setupFifo;

    /** setup structure for UART extend setup */
    void*       extendSetup;
} CSL_UartHwSetup;
/**
@} */


/**
 * Hardware setup Defaults
 *
 */
#define CSL_UART_HWSETUP_DEFAULTS {\
    CSL_UART_AUTO_CTS,             \
    CSL_UART_FIFO_ENABLE,          \
    CSL_UART_LOOP_ENABLE,          \
    CSL_UART_EMU_RUN,              \
    CSL_UART_INTR_ENALL,           \
    {  CSL_UART_CLK_FREQ,  \
       CSL_UART_BAUD_9_6K          \
    },                             \
    {  CSL_UART_CHARLEN_8,         \
       CSL_UART_NUMSTOP_1,         \
       NULL                        \
    },                             \
    {  CSL_UART_RXTRIGLEVEL_1,     \
       CSL_UART_DMA_DISABLE        \
    },                             \
    NULL                           \
};


/**
 * @brief Config-structure Used to configure the UART CSL_uartHwSetupRaw()
 *
 *
 */
typedef struct {
    /** UART Transmitter holding register */
    volatile Uint32 THR;

    /** UART Interrupt holding register */
    volatile Uint32 IER;

    /** UART Frame control register */
    volatile Uint32 FCR;

    /** UART Line control register */
    volatile Uint32 LCR;

    /** UART Modem control register */
    volatile Uint32 MCR;

    /** UART Scratch register register */
    volatile Uint32 SCR;

    /** UART Devisor latch low register */
    volatile Uint8  DLL;

    /** UART Devisor latch high register */
    volatile Uint8  DLH;

    /** UART Power management register */
    volatile Uint32 PWREMU_MGMT;
} CSL_UartConfig;

/** Definition for uart default config structure*/
#define CSL_UART_CONFIG_DEFAULTS {  \
    CSL_UART_THR_RESETVAL,          \
    CSL_UART_IER_RESETVAL,          \
    CSL_UART_FCR_RESETVAL,          \
    CSL_UART_LCR_RESETVAL,          \
    CSL_UART_MCR_RESETVAL,          \
    CSL_UART_SCR_RESETVAL,          \
    CSL_UART_DLL_RESETVAL,          \
    CSL_UART_DLH_RESETVAL,          \
    CSL_UART_PWREMU_MGMT_RESETVAL,  \
}

/**
 *  @addtogroup CSL_UART_DATASTRUCT
 @{
 */

/**
 *  @brief This object contains the reference to the instance of UART
 *  opened using the @a CSL_uartOpen()
 *
 *  The pointer to this is passed to all UART CSL APIs
 *  This structure has the fields required to configure UART for any test
 *  case/application. It should be initialized as per requirements of a
 *  test case/application and passed on to the setup function
 */
typedef struct CSL_UartObj {
    /** This is a pointer to the registers of the
         instance of UART referred to by this object */
    CSL_UartRegsOvly regs;

    /** This is the instance of UART being referred to
         by this object */
    CSL_InstNum  perNum;

⌨️ 快捷键说明

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