arminb73
Junior Member level 3
I am working with the uartns driver, but am having some difficulties understanding the following function:
The second argument of the function takes the following constants:
I've added the XUN_OPTION_DATA_INTR, XUN_OPTION_FIFOS_ENABLE, XUN_OPTION_RESET_TX_FIFO and XUN_OPTION_RESET_RX_FIFO to my UART instance. These have been chosen because I've seen them included in other designs. The problem I am facing is I can't seem to understand their purpose.
Could someone please share with me what options are used for practically?
C:
/****************************************************************************/
/**
*
* Sets the options for the specified driver instance. The options are
* implemented as bit masks such that multiple options may be enabled or
* disabled simultaneously.
*
* The GetOptions function may be called to retrieve the currently enabled
* options. The result is ORed in the desired new settings to be enabled and
* ANDed with the inverse to clear the settings to be disabled. The resulting
* value is then used as the options for the SetOption function call.
*
* @param InstancePtr is a pointer to the XUartNs550 instance.
* @param Options contains the options to be set which are bit masks
* contained in the file xuartns550.h and named XUN_OPTION_*.
*
* @return
* - XST_SUCCESS if the options were set successfully.
* - XST_UART_CONFIG_ERROR if the options could not be set because
* the hardware does not support FIFOs
*
* @note None.
*
*****************************************************************************/
int XUartNs550_SetOptions(XUartNs550 *InstancePtr, u16 Options)
{
u32 Index;
u32 Register;
/*
* Assert validates the input arguments
*/
Xil_AssertNonvoid(InstancePtr != NULL);
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
/*
* Loop through the options table to map the logical options to the
* physical options in the registers of the UART
*/
for (Index = 0; Index < XUN_NUM_OPTIONS; Index++) {
/*
* If the FIFO control register is being read, this is a
* special case that requires special register processing
*/
if (OptionsTable[Index].RegisterOffset == XUN_FCR_OFFSET) {
Register = ReadFcrRegister(InstancePtr->BaseAddress);
} else {
/*
* Read the register which contains option so that the
* register can be changed without destoying any other
* bits of the register
*/
Register = XUartNs550_ReadReg(InstancePtr->BaseAddress,
OptionsTable[Index].RegisterOffset);
}
/*
* If the option is set in the input, then set the
* corresponding bit in the specified register, otherwise
* clear the bit in the register
*/
if (Options & OptionsTable[Index].Option) {
Register |= OptionsTable[Index].Mask;
} else {
Register &= ~OptionsTable[Index].Mask;
}
/*
* Write the new value to the register to set the option
*/
XUartNs550_WriteReg(InstancePtr->BaseAddress,
OptionsTable[Index].RegisterOffset, Register);
}
/* To be done, add error checks for enabling/resetting FIFOs */
return XST_SUCCESS;
}
The second argument of the function takes the following constants:
C:
/** @name Configuration options
* @{
*/
/**
* These constants specify the options that may be set or retrieved
* with the driver, each is a unique bit mask such that multiple options
* may be specified. These constants indicate the function of the option
* when in the active state.
*/
#define XUN_OPTION_RXLINE_INTR 0x0800 /**< Enable status interrupt */
#define XUN_OPTION_SET_BREAK 0x0400 /**< Set a break condition */
#define XUN_OPTION_LOOPBACK 0x0200 /**< Enable local loopback */
#define XUN_OPTION_DATA_INTR 0x0100 /**< Enable data interrupts */
#define XUN_OPTION_MODEM_INTR 0x0080 /**< Enable modem interrupts */
#define XUN_OPTION_FIFOS_ENABLE 0x0040 /**< Enable FIFOs */
#define XUN_OPTION_RESET_TX_FIFO 0x0020 /**< Reset the transmit FIFO */
#define XUN_OPTION_RESET_RX_FIFO 0x0010 /**< Reset the receive FIFO */
#define XUN_OPTION_ASSERT_OUT2 0x0008 /**< Assert out2 signal */
#define XUN_OPTION_ASSERT_OUT1 0x0004 /**< Assert out1 signal */
#define XUN_OPTION_ASSERT_RTS 0x0002 /**< Assert RTS signal */
#define XUN_OPTION_ASSERT_DTR 0x0001 /**< Assert DTR signal */
/*@}*/
I've added the XUN_OPTION_DATA_INTR, XUN_OPTION_FIFOS_ENABLE, XUN_OPTION_RESET_TX_FIFO and XUN_OPTION_RESET_RX_FIFO to my UART instance. These have been chosen because I've seen them included in other designs. The problem I am facing is I can't seem to understand their purpose.
Could someone please share with me what options are used for practically?