uartns550: xuartns550_intr_example.c File Reference

| uartns550 Xilinx SDK Drivers API Documentation

- Overview
- Data Structures
- APIs
- File List
- Examples

Functions
xuartns550_intr_example.c File Reference

## Overview

This file contains a design example using the UART 16450/16550 driver (XUartNs550) and hardware device using interrupt mode.

Note

    MODIFICATION HISTORY:

    Ver   Who  Date     Changes

    1.00b jhl  02/13/02 First release
    1.00b sv   06/08/05 Minor changes to comply to Doxygen and coding guidelines
    1.01a sv   05/08/06 Minor changes for supporting Test App Interrupt examples
    2.00a ktn  10/20/09 Updated to use HAL processor APIs and minor modifications
                  as per coding guidelines.
    2.01a ssb  01/11/01 Updated the example to be used with the SCUGIC in
                  Zynq.
    3.2   adk  15/10/14 Clear the global counters.If multiple instance of ip is
                  present in the h/w design without clearing these counters
                  will result undefined behaviour for the second ip
                          instance while running the peripheral tests.
    3.4   ms   01/23/17 Added xil_printf statement in main function to
                        ensure that "Successfully ran" and "Failed" strings
                        are available in all examples. This is a fix for
                        CR-965028.

## Functions
int | UartNs550IntrExample (INTC *IntcInstancePtr, XUartNs550 *UartInstancePtr, u16 UartDeviceId, u16 UartIntrId)
| This function does a minimal test on the UartNs550 device and driver as a design example. More...
void | UartNs550IntrHandler (void *CallBackRef, u32 Event, unsigned int EventData)
| This function is the handler which performs processing to handle data events from the UartNs550. More...
int | main (void)
| Main function to call the UartNs550 interrupt example. More...

## Function Documentation

int main | ( | void |  | ) |

Main function to call the UartNs550 interrupt example.

Parameters

  None. |

Returns
  XST_SUCCESS if successful, otherwise XST_FAILURE.

Note
  None.

References UartNs550IntrExample().

int UartNs550IntrExample | ( | INTC * | IntcInstancePtr,
|  | XUartNs550 * | UartInstancePtr,
|  | u16 | UartDeviceId,
|  | u16 | UartIntrId
| ) |  |

This function does a minimal test on the UartNs550 device and driver as a design example.

The purpose of this function is to illustrate how to use the XUartNs550 component.

This function transmits data and expects to receive the same data through the UART using the local loopback of the hardware.

This function uses interrupt driver mode of the UART.

Parameters

  IntcInstancePtr | is a pointer to the instance of the Interrupt Controller.
  UartInstancePtr | is a pointer to the instance of the UART .
  UartDeviceId | is the device Id and is typically XPAR_<UARTNS550_instance>_DEVICE_ID value from xparameters.h.
  UartIntrId | is the interrupt Id and is typically XPAR_<INTC_instance>_<UARTNS550_instance>_IP2INTC_IRPT_INTR value from xparameters.h.

Returns
  XST_SUCCESS if successful, otherwise XST_FAILURE.

Note

This function contains an infinite loop such that if interrupts are not working it may never return.

References UartNs550IntrHandler(), XUartNs550_Initialize(), XUartNs550_Recv(), XUartNs550_SelfTest(), XUartNs550_Send(), XUartNs550_SetHandler(), XUartNs550_SetOptions(), XUN_OPTION_DATA_INTR, XUN_OPTION_FIFOS_ENABLE, and XUN_OPTION_LOOPBACK.

Referenced by main().

void UartNs550IntrHandler | ( | void * | CallBackRef,
|  | u32 | Event,
|  | unsigned int | EventData
| ) |  |

This function is the handler which performs processing to handle data events from the UartNs550.

It is called from an interrupt context such that the amount of processing performed should be minimized.

This handler provides an example of how to handle data for the UART and is application specific.

Parameters

  CallBackRef | contains a callback reference from the driver, in thiscase it is the instance pointer for the UART driver.
  Event | contains the specific kind of event that has occurred.
  EventData | contains the number of bytes sent or received for sent and receive events.

Returns
  None.

Note
  None.

References XUartNs550_GetLastErrors(), XUN_EVENT_RECV_DATA, XUN_EVENT_RECV_ERROR, XUN_EVENT_RECV_TIMEOUT, and XUN_EVENT_SENT_DATA.

Referenced by UartNs550IntrExample().