iomodule
Vitis Drivers API Documentation
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
xiomodule_low_level_example.c File Reference

Overview

This file contains a design example using the low level-0 driver, interface of the IO Module driver.

Note

None

MODIFICATION HISTORY:
Ver   Who  Date     Changes


1.00a sa 07/15/11 First release 2.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. 2.15 sa 01/05/23 Updated example to use generic API Xil_ExceptionEnable instead of Microblaze specific API microblaze_enable_interrupts. It is needed to support RISC-V. 2.19 ml 04/15/25 Add support for SDT flow

#include "xparameters.h"
#include "xstatus.h"
#include "xiomodule_l.h"
#include "xil_exception.h"
#include "xil_printf.h"

Macros

#define IOMODULE_BASEADDR   XPAR_IOMODULE_0_BASEADDR
 Base address of the IOModule peripheral. More...
 
#define IOMODULE_DEVICE_INTR_ID   0x7U
 Interrupt ID for the IOModule device. More...
 
#define IOMODULE_DEVICE_INT_MASK   0x80U
 Interrupt mask for the IOModule device. More...
 

Functions

XStatus IOModuleLowLevelExample (u32 IOModuleBaseAddress)
 This function is an example of how to use the IO Module driver component (XIOModule) and the hardware device. More...
 
void SetupInterruptSystem ()
 This function connects the interrupt handler of the IO Module to the processor. More...
 
void DeviceDriverHandler (void *CallbackRef)
 This function is designed to look like an interrupt handler in a device driver. More...
 
int main (void)
 This is the main function for the IO Module Low Level example. More...
 

Macro Definition Documentation

#define IOMODULE_BASEADDR   XPAR_IOMODULE_0_BASEADDR

Base address of the IOModule peripheral.

Referenced by DeviceDriverHandler(), and main().

#define IOMODULE_DEVICE_INT_MASK   0x80U

Interrupt mask for the IOModule device.

Referenced by IOModuleLowLevelExample().

#define IOMODULE_DEVICE_INTR_ID   0x7U

Interrupt ID for the IOModule device.

Referenced by IOModuleLowLevelExample().

Function Documentation

void DeviceDriverHandler ( void *  CallbackRef)

This function is designed to look like an interrupt handler in a device driver.

This is typically a 2nd level handler that is called from the IO Module interrupt handler. This handler would typically perform device specific processing such as reading and writing the registers of the device to clear the interrupt condition and pass any data to an application using the device driver. Many drivers already provide this handler and the user is not required to create it.

Parameters
[in]CallbackRefis passed back to the device driver's interrupt handler by the XIOModule driver. It was given to the XIOModule driver in the XIOModule_Connect() function call. It is typically a pointer to the device driver instance variable if using the Xilinx Level 1 device drivers. In this example, we do not care about the callback reference, so we passed it a 0 when connecting the handler to the XIOModule driver and we make no use of it here.

References IOMODULE_BASEADDR.

Referenced by IOModuleLowLevelExample().

XStatus IOModuleLowLevelExample ( u32  IOModuleBaseAddress)

This function is an example of how to use the IO Module driver component (XIOModule) and the hardware device.

This function is designed to work without external hardware devices to cause interrupts. It may not return if the IO Module is not properly connected to the processor in either software or hardware.

Parameters
[in]IOModuleBaseAddressis Base Address of the the IO Module Device
Returns
XST_SUCCESS to indicate success, otherwise XST_FAILURE

References DeviceDriverHandler(), IOMODULE_DEVICE_INT_MASK, IOMODULE_DEVICE_INTR_ID, SetupInterruptSystem(), XIOModule_EnableIntr, and XIOModule_RegisterHandler().

Referenced by main().

int main ( void  )

This is the main function for the IO Module Low Level example.

Returns
XST_SUCCESS to indicate success, otherwise XST_FAILURE.

References IOMODULE_BASEADDR, and IOModuleLowLevelExample().

void SetupInterruptSystem ( )

This function connects the interrupt handler of the IO Module to the processor.

This function is separate to allow it to be customized for each application. Each processor or RTOS may require unique processing to connect the interrupt handler.

References XIOModule_DeviceInterruptHandler().

Referenced by IOModuleLowLevelExample().