csl_uartaux.h

来自「dsp在音频处理中的运用」· C头文件 代码 · 共 456 行

H
456
字号
/*  =========================================================*   Copyright (c) Texas Instruments Inc 2002, 2003, 2004**   Use of this software is controlled by the terms and conditions found*   in the license agreement under which this software has been supplied*   provided*   ==========================================================*//** @file csl_uartAux.h**  @brief    Header file implementing the static inlined Hardrware Control Commands**  Description*    - This header file implements the hardware control commands. These functions*		are used by the CSL_uartHwControl API.**  @date 28th Jun, 2004*  @author PB*/#ifndef _CSL_UARTAUX_H_#define _CSL_UARTAUX_H_#include <csl_uart.h>#include <_csl_uart.h>#ifdef __cplusplusextern "C" {#endifstatic inlineBool	CSL_uartRead(		CSL_UartHandle 	hUart,		CSL_UartXfer	*xfer){	Uint16 _tmpstat;	_tmpstat = hUart->regs->LSR_XON2;	if ((CSL_FEXT(_tmpstat,UART_LSR_RX_FE))) {	    xfer->error|=CSL_UART_LINESTS_RXFRAME_ERROR;	}	if ((CSL_FEXT(_tmpstat,UART_LSR_RX_PE))) {	    xfer->error|=CSL_UART_LINESTS_PARITY_ERROR;	}	if ((CSL_FEXT(_tmpstat,UART_LSR_RX_BI))) {	    xfer->error|=CSL_UART_LINESTS_BREAK_ERROR;	}	if (CSL_FEXT(_tmpstat,UART_LSR_RX_FIFO_E)) {		xfer->data = hUart->regs->RHR_THR_DLL;		return TRUE;	}	return FALSE;}static inlineBool	CSL_uartWrite(		CSL_UartHandle 	hUart,		CSL_UartXfer	*xfer){	Uint16 _tmpstat;	_tmpstat = hUart->regs->SSR;	if (!CSL_FEXT(_tmpstat,UART_SSR_TX_FIFO_FULL)) {		hUart->regs->RHR_THR_DLL = xfer->data;		return TRUE;	}	return FALSE;}static inlinevoid    CSL_uartReset (        CSL_UartHandle hUart){	CSL_FINST(hUart->regs->SYSC,UART_SYSC_SOFTRESET,ENABLE);	return;}static inlinevoid	CSL_uartSetupWakeEvents (		CSL_UartHandle hUart,		CSL_BitMask16 * cmdArg){	hUart->regs->WER = (Uint8)*cmdArg;	return;}static inlinevoid	CSL_uartSetSpecialChar (			CSL_UartHandle hUart,			Uint8 *cmdArg){	Uint16 _lcrstore;	CSL_UART_LCR_STORE(_lcrstore);	CSL_UART_SETLCR_BF;	hUart->regs->SPR_TLR_XOFF2 = *((Uint8*) cmdArg);	CSL_UART_LCR_RESTORE(_lcrstore);	return;}static inlinevoid	CSL_uartEventEnableDisable (			CSL_UartHandle 			hUart,			CSL_UartHwControlCmd    cmd,			CSL_BitMask16 *			cmdArg){	Uint16 _lcrstore;	Uint16 _tmpstat ;	/* Saving the LCR value(Assumption is LCR[7]=0)    */	CSL_UART_LCR_STORE(_lcrstore);	CSL_UART_SETLCR_BF;	/* Setting EFR[4] = 1     */	CSL_FINST(hUart->regs->IIR_FCR_EFR,UART_EFR_ENHANCED_EN,ENABLE);	/* Setting LCR Bit 7 to 0 */	CSL_UART_SETLCRBIT7_0;	/* Setting IER            */	if (cmd == CSL_UART_CMD_EVENT_ENABLE) {		_tmpstat = hUart->regs->IER_DLH;		_tmpstat |= (Uint8)(*((CSL_BitMask16 *)cmdArg) & 0x00FF);		hUart->regs->IER_DLH = _tmpstat;		/* Check is DSR Interrupt is enabled */		if (*((CSL_BitMask16*) cmdArg) & CSL_UART_EVENT_DSR)		CSL_FINST(hUart->regs->SCR,UART_SCR_DSR_IT,ENABLE);		/* Check is RCD Enable Interrupt is enabled */		if (*((CSL_BitMask16*) cmdArg) & CSL_UART_EVENT_RCDWAKEUP)		CSL_FINST(hUart->regs->SCR,UART_SCR_RX_CTS_DSR_WAKE_UP_ENABLE,ENABLE);	} else {		_tmpstat = hUart->regs->IER_DLH;		_tmpstat &= ~(*((CSL_BitMask16 *)cmdArg));		hUart->regs->IER_DLH = (Uint8)(_tmpstat & 0x00FF);		/* Check is DSR Interrupt is enabled */		if (*((CSL_BitMask16*) cmdArg) & CSL_UART_EVENT_DSR)		CSL_FINST(hUart->regs->SCR,UART_SCR_DSR_IT,DISABLE);		/* Check is RCD Enable Interrupt is enabled */		if (*((CSL_BitMask16*) cmdArg) & CSL_UART_EVENT_RCDWAKEUP)		CSL_FINST(hUart->regs->SCR,UART_SCR_RX_CTS_DSR_WAKE_UP_ENABLE,DISABLE);	}	CSL_UART_SETLCRBIT7_1;	CSL_FINST(hUart->regs->IIR_FCR_EFR,UART_EFR_ENHANCED_EN,DISABLE);	CSL_UART_LCR_RESTORE(_lcrstore);	return;}static inlinevoid	CSL_uartRcvdEventClear (		CSL_UartHandle hUart){	CSL_FINST(hUart->regs->SCR,UART_SCR_RX_CTS_DSR_WAKE_UP_ENABLE,ENABLE);	return;}static inlinevoid	CSL_uartXonAnyEnableDisable (		CSL_UartHandle hUart,		CSL_UartHwControlCmd cmd){	Uint16 _lcrstore;	/* Saving the LCR value(Assumption is LCR[7]=0)    */	CSL_UART_LCR_STORE(_lcrstore);	CSL_UART_SETLCR_BF;	/* Setting EFR[4] = 1  */	CSL_FINST(hUart->regs->IIR_FCR_EFR,UART_EFR_ENHANCED_EN,ENABLE);	/* Setting LCR != 0xBF */	CSL_UART_SETLCRBIT7_0;	/* Setting MCR XONANY bit         */	CSL_FINS(hUart->regs->MCR_XON1,UART_MCR_XON_EN,cmd);	CSL_UART_SETLCRBIT7_1;	CSL_FINST(hUart->regs->IIR_FCR_EFR,UART_EFR_ENHANCED_EN,DISABLE);	/* Restoring the LCR value(Assumption is LCR[7]=0) */	CSL_UART_LCR_RESTORE(_lcrstore);	return;}static inlinevoid	CSL_uartTxEmptyItEnableDisable (		CSL_UartHandle hUart,		CSL_UartHwControlCmd cmd){	CSL_FINS(hUart->regs->SCR,UART_SCR_TX_EMPTY_CTL_IT,cmd);	return;}static inlinevoid	CSL_uartRtsEnableDisable (		CSL_UartHandle hUart,		CSL_UartHwControlCmd cmd){	/* Assumption : LCR != 0xBF i.e LCR[7] = 0 Normal Operating Mode */	CSL_FINS(hUart->regs->MCR_XON1,UART_MCR_RTS,cmd);	return;}static inlinevoid	CSL_uartDtrEnableDisable (		CSL_UartHandle hUart,		CSL_UartHwControlCmd cmd){	/* Assumption : LCR != 0xBF i.e LCR[7] = 0 Normal Operating Mode */	CSL_FINS(hUart->regs->MCR_XON1, UART_MCR_DTR,cmd);	return;}static inlinevoid	CSL_uartRiHighLow (		CSL_UartHandle hUart,		CSL_UartHwControlCmd cmd){	/* Assumption : LCR != 0xBF i.e LCR[7] = 0 Normal	Operating Mode */	CSL_FINS(hUart->regs->MCR_XON1, UART_MCR_RI_STS_CH,cmd);	return;}static inlinevoid	CSL_uartDcdHighLow (		CSL_UartHandle hUart,		CSL_UartHwControlCmd cmd){	/* Assumption : LCR != 0xBF i.e LCR[7] = 0 Normal	Operating Mode */	CSL_FINS(hUart->regs->MCR_XON1, UART_MCR_CD_STS_CH,cmd);	return;}static inlinevoid	CSL_uartSysAutoIdle (		CSL_UartHandle hUart,		CSL_UartHwControlCmd cmd){	CSL_FINS(hUart->regs->SYSC,UART_SYSC_AUTOIDLE,cmd);	return;}static inlinevoid	CSL_uartSysWakeEnableDisable (		CSL_UartHandle hUart,		CSL_UartHwControlCmd cmd){	CSL_FINS(hUart->regs->SYSC,UART_SYSC_ENAWAKEUP,cmd);	return;}static inlinevoid	CSL_uartSpCharDetectEnableDisable (		CSL_UartHandle hUart,		CSL_UartHwControlCmd cmd){	Uint16 _lcrstore;	CSL_UART_LCR_STORE(_lcrstore);	CSL_UART_SETLCR_BF;	CSL_FINS(hUart->regs->IIR_FCR_EFR,UART_EFR_SPECIAL_CHAR_DETECT,cmd);	CSL_UART_LCR_RESTORE(_lcrstore);	return;}static inlinevoid	CSL_uartBreakEnableDisable (		CSL_UartHandle hUart,		CSL_UartHwControlCmd cmd){	CSL_FINS(hUart->regs->LCR,UART_LCR_BREAK_EN,cmd);	return;}static inlinevoid	CSL_uartSysIdleMode (		CSL_UartHandle hUart,		CSL_UartHwControlCmd cmd){	CSL_FINS(hUart->regs->SYSC,UART_SYSC_IDLEMODE,cmd);	return;}static inlinevoid	CSL_uartQueryEvents (		/** Pointer to the object that holds reference to the     	* instance of UART */		CSL_UartHandle           hUart,		/** Placeholder to return the status; @a void* casted */		CSL_BitMask16            *response){	Uint16 _lcrstore,_tempVal;	/* Saving the LCR value */	CSL_UART_LCR_STORE(_lcrstore);	/* Reading IER         */	*(response) = hUart->regs->IER_DLH ;	/* Check is DSR Interrupt is enabled */	_tempVal = hUart->regs->SCR;	if (CSL_FEXT(_tempVal,UART_SCR_DSR_IT))	*(response)|= CSL_UART_EVENT_DSR;	if (CSL_FEXT(_tempVal,UART_SCR_RX_CTS_DSR_WAKE_UP_ENABLE))	*(response)|= CSL_UART_EVENT_RCDWAKEUP;	CSL_UART_LCR_RESTORE(_lcrstore);	return;}static inlinevoid	CSL_uartQueryWakeupEvents(		/** Pointer to the object that holds reference to the     	* instance of UART */		CSL_UartHandle           hUart,		/** Placeholder to return the status; @a void* casted */		CSL_BitMask16            *response){	*response = hUart->regs->WER;}static inlinevoid	CSL_uartQueryLineStatus(		/** Pointer to the object that holds reference to the     	* instance of UART */		CSL_UartHandle           hUart,		/** Placeholder to return the status; @a void* casted */		CSL_BitMask16            *response){	/* Assumption: LSR !=0xBF i.e If in Normal Operating Mode	sufficient */	*(response) = hUart->regs->LSR_XON2;}static inlinevoid	CSL_uartQueryModemStatus(		/** Pointer to the object that holds reference to the     	* instance of UART */		CSL_UartHandle           hUart,		/** Placeholder to return the status; @a void* casted */		CSL_BitMask16            *response){	/* Assumption: LSR !=0xBF i.e If in Normal Operating Mode	sufficient , EFR[4] = 0*/	*(response) = hUart->regs->MSR_TCR_XOFF1;}static inlinevoid	CSL_uartQuerySuppStatus(		/** Pointer to the object that holds reference to the     	* instance of UART */		CSL_UartHandle           hUart,		/** Placeholder to return the status; @a void* casted */		CSL_BitMask16            *response){	*(response) = hUart->regs->SSR;}static inlinevoid	CSL_uartQueryAutoBaud(		/** Pointer to the object that holds reference to the     	* instance of UART */		CSL_UartHandle           hUart,		/** Placeholder to return the status; @a void* casted */		CSL_UartAutoBaud         *response){	Uint16 _lcrstore, _tempVal;	CSL_UartAutoBaud* _tmpAutoBaud;	_tmpAutoBaud = (CSL_UartAutoBaud*)response;	CSL_UART_LCR_STORE(_lcrstore);	CSL_UART_SETLCR_BF;	_tempVal = hUart->regs->UASR;	_tmpAutoBaud->speed = (CSL_UartAutoBaudSpeed)(CSL_FEXT(_tempVal,UART_UASR_SPEED));	_tmpAutoBaud->bits  = (CSL_UartAutoBitperChar)(CSL_FEXT(_tempVal,UART_UASR_BIT_BY_CHAR));	_tmpAutoBaud->parity = (CSL_UartAutoParity)(CSL_FEXT(_tempVal,UART_UASR_PARITY_TYPE));	CSL_UART_LCR_RESTORE(_lcrstore);}static inlinevoid	CSL_uartQueryVersion(		/** Pointer to the object that holds reference to the     	* instance of UART */		CSL_UartHandle           hUart,		/** Placeholder to return the status; @a void* casted */		Uint16			         *response){	*((Uint16*)response) = hUart->regs->MVR;}static inlinevoid	CSL_uartQueryIntrSource(		/** Pointer to the object that holds reference to the     	* instance of UART */		CSL_UartHandle           hUart,		/** Placeholder to return the status; @a void* casted */		CSL_UartIntrSource			         *response){	/*Assumption: LSR !=0xBF i.e If in Normal Operating Mode	sufficient	*/	*(response) = (CSL_UartIntrSource)(CSL_FEXTR(hUart->regs->IIR_FCR_EFR,5,0));}static inlinevoid	CSL_uartQueryReset(		/** Pointer to the object that holds reference to the     	* instance of UART */		CSL_UartHandle           hUart,		/** Placeholder to return the status; @a void* casted */		Bool			         *response){	if (CSL_FEXT(hUart->regs->SYSS,UART_SYSS_RESETDONE))		*(response) = TRUE;	else		*(response) = FALSE;}#ifdef __cplusplus}#endif#endif /* _CSL_UARTAUX_H_*/

⌨️ 快捷键说明

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