Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Purpose of XUartNs550_SetOptions function?

Status
Not open for further replies.

arminb73

Junior Member level 3
Joined
Nov 9, 2021
Messages
26
Helped
0
Reputation
0
Reaction score
1
Trophy points
3
Activity points
185
I am working with the uartns driver, but am having some difficulties understanding the following function:

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?
 

Hi,

in the "define" section there are comments. They tell you what each option does.

So XUN_OPTION_DATA_INTR enables the data interrupt.
What additional information do you need?
Did you read the documentation?

Klaus
 

Hello Klaus,

Thank you for your answer. What does data interrupt mean? I've been looking online, for example, design from Xilinx, and also read the documentation. I still don't have a clear understanding of what it really means though.
 

Attachments

  • 2.jpg
    2.jpg
    17.2 KB · Views: 133
  • 1.jpg
    1.jpg
    146.4 KB · Views: 127

It seems clear to me that the data interrupt is when the rx data level in the fifo is above a certain level.
It says that in the Receive Data Available paragraph.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top