xiomodule.c File Reference
#include "xiomodule.h"
#include "xiomodule_l.h"
#include "xiomodule_i.h"
#include "xiomodule_io.h"
#include "xil_types.h"
#include "xil_assert.h"
Functions |
int | XIOModule_Initialize (XIOModule *InstancePtr, u16 DeviceId) |
int | XIOModule_Start (XIOModule *InstancePtr) |
void | XIOModule_Stop (XIOModule *InstancePtr) |
int | XIOModule_Connect (XIOModule *InstancePtr, u8 Id, XInterruptHandler Handler, void *CallBackRef) |
void | XIOModule_Disconnect (XIOModule *InstancePtr, u8 Id) |
void | XIOModule_Enable (XIOModule *InstancePtr, u8 Id) |
void | XIOModule_Disable (XIOModule *InstancePtr, u8 Id) |
void | XIOModule_Acknowledge (XIOModule *InstancePtr, u8 Id) |
XIOModule_Config * | XIOModule_LookupConfig (u16 DeviceId) |
int | XIOModule_ConnectFastHandler (XIOModule *InstancePtr, u8 Id, XFastInterruptHandler Handler) |
void | XIOModule_SetNormalIntrMode (XIOModule *InstancePtr, u8 Id) |
u32 | XIOModule_DiscreteRead (XIOModule *InstancePtr, unsigned Channel) |
void | XIOModule_DiscreteWrite (XIOModule *InstancePtr, unsigned Channel, u32 Data) |
int | XIOModule_Timer_Initialize (XIOModule *InstancePtr, u16 DeviceId) |
void | XIOModule_Timer_Start (XIOModule *InstancePtr, u8 TimerNumber) |
void | XIOModule_Timer_Stop (XIOModule *InstancePtr, u8 TimerNumber) |
u32 | XIOModule_GetValue (XIOModule *InstancePtr, u8 TimerNumber) |
void | XIOModule_SetResetValue (XIOModule *InstancePtr, u8 TimerNumber, u32 ResetValue) |
u32 | XIOModule_GetCaptureValue (XIOModule *InstancePtr, u8 TimerNumber) |
void | XIOModule_Reset (XIOModule *InstancePtr, u8 TimerNumber) |
int | XIOModule_IsExpired (XIOModule *InstancePtr, u8 TimerNumber) |
u32 | XIOModule_IoReadWord (XIOModule *InstancePtr, u32 ByteOffset) |
u16 | XIOModule_IoReadHalfword (XIOModule *InstancePtr, u32 ByteOffset) |
u8 | XIOModule_IoReadByte (XIOModule *InstancePtr, u32 ByteOffset) |
void | XIOModule_IoWriteWord (XIOModule *InstancePtr, u32 ByteOffset, u32 Data) |
void | XIOModule_IoWriteHalfword (XIOModule *InstancePtr, u32 ByteOffset, u16 Data) |
void | XIOModule_IoWriteByte (XIOModule *InstancePtr, u32 ByteOffset, u8 Data) |
Variables |
u32 | XIOModule_BitPosMask [XPAR_IOMODULE_INTC_MAX_INTR_SIZE] |
Detailed Description
Contains required functions for the XIomodule driver for the Xilinx IO Module Interrupt Controller. See xiomodule.h for a detailed description of the driver.
MODIFICATION HISTORY:
Ver Who Date Changes
----- ---- -------- --------------------------------------------------------
1.00a sa 07/15/11 First release
1.01a sa 04/10/12 Updated with fast interrupt
2.1 bss 05/02/14 Modified XIOModule_IsExpired to check for all 1's instead
of 0 in CounterReg.(CR#794167)
Function Documentation
void XIOModule_Acknowledge |
( |
XIOModule * |
InstancePtr, |
|
|
u8 |
Id | |
|
) |
| | |
Acknowledges the interrupt source provided as the argument Id. When the interrupt is acknowledged, it causes the interrupt controller to clear its interrupt condition.
- Parameters:
-
| InstancePtr | is a pointer to the XIOModule instance to be worked on. |
| Id | contains the ID of the interrupt source and should be in the range of 0 to XPAR_IOMODULE_INTC_MAX_INTR_SIZE - 1 with 0 being the highest priority interrupt. |
- Returns:
- None.
- Note:
- None.
int XIOModule_Connect |
( |
XIOModule * |
InstancePtr, |
|
|
u8 |
Id, |
|
|
XInterruptHandler |
Handler, |
|
|
void * |
CallBackRef | |
|
) |
| | |
Makes the connection between the Id of the interrupt source and the associated handler that is to run when the interrupt is recognized. The argument provided in this call as the Callbackref is used as the argument for the handler when it is called.
- Parameters:
-
| InstancePtr | is a pointer to the XIOModule instance to be worked on. |
| Id | contains the ID of the interrupt source and should be in the range of 0 to XPAR_IOMODULE_INTC_MAX_INTR_SIZE - 1 with 0 being the highest priority interrupt. |
| Handler | to the handler for that interrupt. |
| CallBackRef | is the callback reference, usually the instance pointer of the connecting driver. |
- Returns:
- XST_SUCCESS if the handler was connected correctly.
- Note:
- Only used with normal interrupt mode. Does not restore normal interrupt mode.
WARNING: The handler provided as an argument will overwrite any handler that was previously connected.
Makes the connection between the Id of the interrupt source and the associated handler that is to run when the interrupt is recognized.
- Parameters:
-
| InstancePtr | is a pointer to the XIOModule instance. |
| Id | contains the ID of the interrupt source and should be in the range of 0 to XPAR_INTC_MAX_NUM_INTR_INPUTS - 1 with 0 being the highest priority interrupt. |
| Handler | to the handler for that interrupt. |
- Returns:
- XST_SUCCESS if the handler was connected correctly.
- Note:
- Only used with fast interrupt mode.
WARNING: The handler provided as an argument will overwrite any handler that was previously connected.
void XIOModule_Disable |
( |
XIOModule * |
InstancePtr, |
|
|
u8 |
Id | |
|
) |
| | |
Disables the interrupt source provided as the argument Id such that the interrupt controller will not cause interrupts for the specified Id. The interrupt controller will continue to hold an interrupt condition for the Id, but will not cause an interrupt.
- Parameters:
-
| InstancePtr | is a pointer to the XIOModule instance to be worked on. |
| Id | contains the ID of the interrupt source and should be in the range of 0 to XPAR_IOMODULE_INTC_MAX_INTR_SIZE - 1 with 0 being the highest priority interrupt. |
- Returns:
- None.
- Note:
- None.
void XIOModule_Disconnect |
( |
XIOModule * |
InstancePtr, |
|
|
u8 |
Id | |
|
) |
| | |
Updates the interrupt table with the Null Handler and NULL arguments at the location pointed at by the Id. This effectively disconnects that interrupt source from any handler. The interrupt is disabled also.
- Parameters:
-
| InstancePtr | is a pointer to the XIOModule instance to be worked on. |
| Id | contains the ID of the interrupt source and should be in the range of 0 to XPAR_IOMODULE_INTC_MAX_INTR_SIZE - 1 with 0 being the highest priority interrupt. |
- Returns:
- None.
- Note:
- None.
u32 XIOModule_DiscreteRead |
( |
XIOModule * |
InstancePtr, |
|
|
unsigned |
Channel | |
|
) |
| | |
Read state of discretes for the specified GPI channnel.
- Parameters:
-
| InstancePtr | is a pointer to an XIOModule instance to be worked on. |
| Channel | contains the channel of the GPI (1, 2, 3 or 4) to operate on. |
- Returns:
- Current copy of the discretes register.
void XIOModule_DiscreteWrite |
( |
XIOModule * |
InstancePtr, |
|
|
unsigned |
Channel, |
|
|
u32 |
Data | |
|
) |
| | |
Write to discretes register for the specified GPO channel.
- Parameters:
-
| InstancePtr | is a pointer to an XIOModule instance to be worked on. |
| Channel | contains the channel of the GPO (1, 2, 3 or 4) to operate on. |
| Data | is the value to be written to the discretes register. |
- Returns:
- None.
void XIOModule_Enable |
( |
XIOModule * |
InstancePtr, |
|
|
u8 |
Id | |
|
) |
| | |
Enables the interrupt source provided as the argument Id. Any pending interrupt condition for the specified Id will occur after this function is called.
- Parameters:
-
| InstancePtr | is a pointer to the XIOModule instance to be worked on. |
| Id | contains the ID of the interrupt source and should be in the range of 0 to XPAR_IOMODULE_INTC_MAX_INTR_SIZE - 1 with 0 being the highest priority interrupt. |
- Returns:
- None.
- Note:
- None.
u32 XIOModule_GetCaptureValue |
( |
XIOModule * |
InstancePtr, |
|
|
u8 |
TimerNumber | |
|
) |
| | |
Returns the timer counter value that was captured the last time the external capture input was asserted.
- Parameters:
-
| InstancePtr | is a pointer to the XIOModule instance. |
| TimerNumber | is the timer counter of the device to operate on. Each device may contain multiple timer counters. The timer number is a zero based number with a range of 0 to (XTC_DEVICE_TIMER_COUNT - 1). |
- Returns:
- The current capture value for the indicated timer counter.
- Note:
- None.
u32 XIOModule_GetValue |
( |
XIOModule * |
InstancePtr, |
|
|
u8 |
TimerNumber | |
|
) |
| | |
Get the current value of the specified timer counter. The timer counter may be either incrementing or decrementing based upon the current mode of operation.
- Parameters:
-
| InstancePtr | is a pointer to the XIOModule instance. |
| TimerNumber | is the timer counter of the device to operate on. Each device may contain multiple timer counters. The timer number is a zero based number with a range of 0 to (XTC_DEVICE_TIMER_COUNT - 1). |
- Returns:
- The current value for the timer counter.
- Note:
- None.
int XIOModule_Initialize |
( |
XIOModule * |
InstancePtr, |
|
|
u16 |
DeviceId | |
|
) |
| | |
Initialize a specific interrupt controller instance/driver. The initialization entails:
- Initialize fields of the XIOModule structure
- Initial vector table with stub function calls
- All interrupt sources are disabled
- Interrupt output is disabled
- All timers are initialized
- Parameters:
-
| InstancePtr | is a pointer to the XIOModule instance to be worked on. |
| DeviceId | is the unique id of the device controlled by this XIOModule instance. Passing in a device id associates the generic XIOModule instance to a specific device, as chosen by the caller or application developer. |
- Returns:
- XST_SUCCESS if initialization was successful
- XST_DEVICE_IS_STARTED if the device has already been started
- XST_DEVICE_NOT_FOUND if device configuration information was not found for a device with the supplied device ID.
- Note:
- None.
u8 XIOModule_IoReadByte |
( |
XIOModule * |
InstancePtr, |
|
|
u32 |
ByteOffset | |
|
) |
| | |
Read byte from the IO Bus memory mapped IO
- Parameters:
-
| InstancePtr | is a pointer to an XIOModule instance to be worked on. |
| ByteOffset | is a byte offset from the beginning of the IO Bus address area |
- Returns:
- Value read from the IO Bus - 8-bit byte
u16 XIOModule_IoReadHalfword |
( |
XIOModule * |
InstancePtr, |
|
|
u32 |
ByteOffset | |
|
) |
| | |
Read 16-bit halfword from the IO Bus memory mapped IO
- Parameters:
-
| InstancePtr | is a pointer to an XIOModule instance to be worked on. |
| ByteOffset | is a byte offset from the beginning of the IO Bus address area |
- Returns:
- Value read from the IO Bus - 16-bit halfword
u32 XIOModule_IoReadWord |
( |
XIOModule * |
InstancePtr, |
|
|
u32 |
ByteOffset | |
|
) |
| | |
Read 32-bit word from the IO Bus memory mapped IO
- Parameters:
-
| InstancePtr | is a pointer to an XIOModule instance to be worked on. |
| ByteOffset | is a byte offset from the beginning of the IO Bus address area |
- Returns:
- Value read from the IO Bus - 32-bit word
void XIOModule_IoWriteByte |
( |
XIOModule * |
InstancePtr, |
|
|
u32 |
ByteOffset, |
|
|
u8 |
Data | |
|
) |
| | |
Write 8-bit word to the IO Bus memory mapped IO
- Parameters:
-
| InstancePtr | is a pointer to an XIOModule instance to be worked on. |
| ByteOffset | is a byte offset from the beginning of the IO Bus address area |
| Data | is the value to be written to the IO Bus - 8-bit |
- Returns:
- None.
void XIOModule_IoWriteHalfword |
( |
XIOModule * |
InstancePtr, |
|
|
u32 |
ByteOffset, |
|
|
u16 |
Data | |
|
) |
| | |
Write 16-bit word to the IO Bus memory mapped IO
- Parameters:
-
| InstancePtr | is a pointer to an XIOModule instance to be worked on. |
| ByteOffset | is a byte offset from the beginning of the IO Bus address area |
| Data | is the value to be written to the IO Bus - 16-bit |
- Returns:
- None.
void XIOModule_IoWriteWord |
( |
XIOModule * |
InstancePtr, |
|
|
u32 |
ByteOffset, |
|
|
u32 |
Data | |
|
) |
| | |
Write 32-bit word to the IO Bus memory mapped IO
- Parameters:
-
| InstancePtr | is a pointer to an XIOModule instance to be worked on. |
| ByteOffset | is a byte offset from the beginning of the IO Bus address area |
| Data | is the value to be written to the IO Bus - 32-bit |
- Returns:
- None.
int XIOModule_IsExpired |
( |
XIOModule * |
InstancePtr, |
|
|
u8 |
TimerNumber | |
|
) |
| | |
Checks if the specified timer counter of the device has expired. In capture mode, expired is defined as a capture occurred. In compare mode, expired is defined as the timer counter rolled over/under for up/down counting.
When interrupts are enabled, the expiration causes an interrupt. This function is typically used to poll a timer counter to determine when it has expired.
- Parameters:
-
| InstancePtr | is a pointer to the XIOModule instance. |
| TimerNumber | is the timer counter of the device to operate on. Each device may contain multiple timer counters. The timer number is a zero based number with a range of 0 to (XTC_DEVICE_TIMER_COUNT - 1). |
- Returns:
- TRUE if the timer has expired, and FALSE otherwise.
- Note:
- None.
Looks up the device configuration based on the unique device ID. A table contains the configuration info for each device in the system.
- Parameters:
-
| DeviceId | is the unique identifier for a device. |
- Returns:
- A pointer to the XIOModule configuration structure for the specified device, or NULL if the device was not found.
- Note:
- None.
void XIOModule_Reset |
( |
XIOModule * |
InstancePtr, |
|
|
u8 |
TimerNumber | |
|
) |
| | |
Resets the specified timer counter of the device. A reset causes the timer counter to set it's value to the reset value.
- Parameters:
-
| InstancePtr | is a pointer to the XIOModule instance. |
| TimerNumber | is the timer counter of the device to operate on. Each device may contain multiple timer counters. The timer number is a zero based number with a range of 0 to (XTC_DEVICE_TIMER_COUNT - 1). |
- Returns:
- None.
- Note:
- None.
void XIOModule_SetNormalIntrMode |
( |
XIOModule * |
InstancePtr, |
|
|
u8 |
Id | |
|
) |
| | |
Sets the normal interrupt mode for the specified interrupt in the Interrupt Mode Register, by resetting the vector to (BaseVector & 0xFFFFFF80) | 0x10 and selecting normal mode.
- Parameters:
-
| InstancePtr | is a pointer to the XIOModule instance. |
| Id | contains the ID of the interrupt source and should be in the range of 0 to XPAR_INTC_MAX_NUM_INTR_INPUTS - 1 with 0 being the highest priority interrupt. |
- Returns:
- None.
- Note:
- Only used with fast interrupt mode.
void XIOModule_SetResetValue |
( |
XIOModule * |
InstancePtr, |
|
|
u8 |
TimerNumber, |
|
|
u32 |
ResetValue | |
|
) |
| | |
Set the reset value for the specified timer counter. This is the value that is loaded into the timer counter when it is reset. This value is also loaded when the timer counter is started.
- Parameters:
-
| InstancePtr | is a pointer to the XIOModule instance. |
| TimerNumber | is the timer counter of the device to operate on. Each device may contain multiple timer counters. The timer number is a zero based number with a range of 0 to (XTC_DEVICE_TIMER_COUNT - 1). |
| ResetValue | contains the value to be used to reset the timer counter. |
- Returns:
- None.
- Note:
- None.
int XIOModule_Start |
( |
XIOModule * |
InstancePtr |
) |
|
Starts the IO Module. Interrupts may be generated by the IO Module after this function is called.
It is necessary for the caller to connect the interrupt handler of this component to the proper interrupt source.
- Parameters:
-
| InstancePtr | is a pointer to the XIOModule instance to be worked on. |
- Returns:
- XST_SUCCESS if the device was started successfully
- XST_FAILURE if simulation mode was specified and it could not be set because real mode has already been entered.
- Note:
- Must be called after XIOModule initialization is completed.
void XIOModule_Stop |
( |
XIOModule * |
InstancePtr |
) |
|
Stops the interrupt controller by disabling the output from the controller so that no interrupts will be caused by the interrupt controller.
- Parameters:
-
| InstancePtr | is a pointer to the XIOModule instance to be worked on. |
- Returns:
- None.
- Note:
- None.
int XIOModule_Timer_Initialize |
( |
XIOModule * |
InstancePtr, |
|
|
u16 |
DeviceId | |
|
) |
| | |
Initializes a specific timer instance/driver. Initialize fields of the XIOModule structure, then reset the timer
- Parameters:
-
| InstancePtr | is a pointer to the XIOModule instance. |
| DeviceId | is the unique id of the device controlled by this XIOModule component. Passing in a device id associates the generic XIOModule component to a specific device, as chosen by the caller or application developer. |
- Returns:
- XST_SUCCESS if initialization was successful
- XST_DEVICE_IS_STARTED if the device has already been started
- XST_DEVICE_NOT_FOUND if the device doesn't exist
- Note:
- None.
void XIOModule_Timer_Start |
( |
XIOModule * |
InstancePtr, |
|
|
u8 |
TimerNumber | |
|
) |
| | |
Starts the specified timer counter of the device such that it starts running. The timer counter is reset before it is started and the reset value is loaded into the timer counter.
If interrupt mode is specified in the options, it is necessary for the caller to connect the interrupt handler of the timer to the interrupt source, typically an interrupt controller, and enable the interrupt within the interrupt controller.
- Parameters:
-
| InstancePtr | is a pointer to the XIOModule instance. |
| TimerNumber | is the timer of the device to operate on. Each device may contain multiple timers. The timer number is a zero based number with a range of 0 to (XTC_DEVICE_TIMER_COUNT - 1). |
- Returns:
- None.
- Note:
- None.
void XIOModule_Timer_Stop |
( |
XIOModule * |
InstancePtr, |
|
|
u8 |
TimerNumber | |
|
) |
| | |
Stops the timer by disabling it.
It is the callers' responsibility to disconnect the interrupt handler of the timer from the interrupt source, typically an interrupt controller, and disable the interrupt within the interrupt controller.
- Parameters:
-
| InstancePtr | is a pointer to the XIOModule instance. |
| TimerNumber | is the timer counter of the device to operate on. Each device may contain multiple timer counters. The timer number is a zero based number with a range of 0 to (XTC_DEVICE_TIMER_COUNT - 1). |
- Returns:
- None.
- Note:
- None.
Variable Documentation
Copyright © 1995-2014 Xilinx, Inc. All rights reserved.