ADuCM302x Device Drivers API Reference Manual  Release 3.1.2.0
External Interrupt Driver

External Interrupt (XINT) Driver. More...

Macros

#define ADI_XINT_MEMORY_SIZE   (48u)
 

Enumerations

enum  ADI_XINT_RESULT {
  ADI_XINT_SUCCESS = 0,
  ADI_XINT_FAILURE,
  ADI_XINT_ALREADY_INITIALIZED,
  ADI_XINT_NOT_INITIALIZED,
  ADI_XINT_NULL_PARAMETER,
  ADI_XINT_INVALID_MEMORY_SIZE,
  ADI_XINT_INVALID_INTERRUPT
}
 
enum  ADI_XINT_IRQ_MODE {
  ADI_XINT_IRQ_RISING_EDGE = 0x0,
  ADI_XINT_IRQ_FALLING_EDGE = 0x1,
  ADI_XINT_IRQ_EITHER_EDGE = 0x2,
  ADI_XINT_IRQ_HIGH_LEVEL = 0x3,
  ADI_XINT_IRQ_LOW_LEVEL = 0x4
}
 
enum  ADI_XINT_EVENT {
  ADI_XINT_EVENT_INT0 = 0x0,
  ADI_XINT_EVENT_INT1 = 0x1,
  ADI_XINT_EVENT_INT2 = 0x2,
  ADI_XINT_EVENT_INT3 = 0x3,
  ADI_XINT_EVENT_RESERVED = 0x4,
  ADI_XINT_EVENT_UART_RX = 0x5,
  ADI_XINT_EVENT_MAX = 0x6
}
 

Functions

ADI_XINT_RESULT adi_xint_Init (void *const pMemory, uint32_t const MemorySize)
 Initializes the External Interrupt Driver. More...
 
ADI_XINT_RESULT adi_xint_UnInit (void)
 Un-initialize the external interrupt driver. More...
 
ADI_XINT_RESULT adi_xint_EnableIRQ (const ADI_XINT_EVENT eEvent, const ADI_XINT_IRQ_MODE eMode)
 Enable an External Interrupt. More...
 
ADI_XINT_RESULT adi_xint_DisableIRQ (const ADI_XINT_EVENT eEvent)
 Disable an External Interrupt. More...
 
ADI_XINT_RESULT adi_xint_RegisterCallback (const ADI_XINT_EVENT eEvent, ADI_CALLBACK const pfCallback, void *const pCBParam)
 Register or unregister an application callback function for external pin interrupts. More...
 

Detailed Description

External Interrupt (XINT) Driver.

Note
The application must include drivers/xint/adi_xint.h to use this driver

Macro Definition Documentation

◆ ADI_XINT_MEMORY_SIZE

#define ADI_XINT_MEMORY_SIZE   (48u)

Amount of memory(in bytes) required by the External Interrupt device driver for its operation. This memory is completely owned by the driver till the end of the operation.

Definition at line 72 of file adi_xint.h.

Referenced by adi_xint_Init().

Enumeration Type Documentation

◆ ADI_XINT_RESULT

External Interrupt Driver API function return codes

Enumerator
ADI_XINT_SUCCESS 

API successfully returned.

ADI_XINT_FAILURE 

The API call failed.

ADI_XINT_ALREADY_INITIALIZED 

External interrupt driver has already been initialized.

ADI_XINT_NOT_INITIALIZED 

External interrupt driver has not yet been initialized.

ADI_XINT_NULL_PARAMETER 

The given pointer is pointing to NULL.

ADI_XINT_INVALID_MEMORY_SIZE 

The given memory is not sufficient to operate the driver.

ADI_XINT_INVALID_INTERRUPT 

Invalid interrupt number.

Definition at line 75 of file adi_xint.h.

◆ ADI_XINT_IRQ_MODE

External interrupt trigger condition enumerations

Enumerator
ADI_XINT_IRQ_RISING_EDGE 

Trigger an interrupt when a rising edge is detected.

ADI_XINT_IRQ_FALLING_EDGE 

Trigger an interrupt when on a falling edge is detected.

ADI_XINT_IRQ_EITHER_EDGE 

Trigger an interrupt on either falling or rising edge is detected.

ADI_XINT_IRQ_HIGH_LEVEL 

Trigger an interrupt on a logic level high is detected.

ADI_XINT_IRQ_LOW_LEVEL 

Trigger an interrupt on a logic level low is detected.

Definition at line 88 of file adi_xint.h.

◆ ADI_XINT_EVENT

External interrupts.

Enumerator
ADI_XINT_EVENT_INT0 

Event for external interrupt-0

ADI_XINT_EVENT_INT1 

Event for external interrupt-1

ADI_XINT_EVENT_INT2 

Event for external interrupt-2

ADI_XINT_EVENT_INT3 

Event for external interrupt-3

ADI_XINT_EVENT_RESERVED 

Event is reserved.

ADI_XINT_EVENT_UART_RX 

Event for UART Rx activity

ADI_XINT_EVENT_MAX 

Number of external interrupt events

Definition at line 97 of file adi_xint.h.

Function Documentation

◆ adi_xint_Init()

ADI_XINT_RESULT adi_xint_Init ( void *const  pMemory,
uint32_t const  MemorySize 
)

Initializes the External Interrupt Driver.

This function does the external interrupt driver initialization. This function should be called before calling any of the XINT driver APIs.

Parameters
[in]pMemoryPointer to the memory to be used by the driver. Size of the memory should be at equal to ADI_XINT_MEMORY_SIZE bytes.
[in]MemorySizeSize of the memory passed in pMemory parameter.
Returns
Status
  • ADI_XINT_SUCCESS If successfully initialized XINT driver.
  • ADI_XINT_NULL_PARAMETER [D] If the given pointer to the driver memory is pointing to NULL.
  • ADI_XINT_INVALID_MEMORY_SIZE [D] If the given memory size is not sufficient to operate the driver.
See also
adi_xint_UnInit

Definition at line 107 of file adi_xint.c.

◆ adi_xint_UnInit()

ADI_XINT_RESULT adi_xint_UnInit ( void  )

Un-initialize the external interrupt driver.

Terminates the XINT functions, leaving everything unchanged.

Returns
Status
See also
adi_xint_Init

Definition at line 149 of file adi_xint.c.

◆ adi_xint_EnableIRQ()

ADI_XINT_RESULT adi_xint_EnableIRQ ( const ADI_XINT_EVENT  eEvent,
const ADI_XINT_IRQ_MODE  eMode 
)

Enable an External Interrupt.

Enables and sets the triggering mode for the given external interrupt. Applications may register a callback using the adi_xint_RegisterCallback API to get a notification when the interrupt occurs.

To get the external interrupt working application has to enable the input (using the GPIO driver API adi_gpio_InputEnable) for the corresponding GPIO pin. Please refer the GPIO chapter pin-muxing section of the Hardware Reference Manual to see the GPIO pin that is mapped to the required external interrupt.

Parameters
[in]eEventEvent which needs to be enabled.
[in]eModeInterrupt trigger mode for the external interrupt.
Returns
Status
See also
adi_xint_DisableIRQ
adi_xint_RegisterCallback

Definition at line 191 of file adi_xint.c.

◆ adi_xint_DisableIRQ()

ADI_XINT_RESULT adi_xint_DisableIRQ ( const ADI_XINT_EVENT  eEvent)

Disable an External Interrupt.

Disables an external interrupt

Parameters
[in]eEventExternal Interrupt event that should be disabled.
Returns
Status
See also
adi_xint_EnableIRQ
adi_xint_RegisterCallback

Definition at line 261 of file adi_xint.c.

◆ adi_xint_RegisterCallback()

ADI_XINT_RESULT adi_xint_RegisterCallback ( const ADI_XINT_EVENT  eEvent,
ADI_CALLBACK const  pfCallback,
void *const  pCBParam 
)

Register or unregister an application callback function for external pin interrupts.

Applications may register a callback function that will be called when an external interrupt occurs. In addition to registering the interrupt, the application should call the adi_xint_EnableIRQ API to enable the external pin interrupt.

The driver dispatches calls to registered callback functions when the properly configured pin(s) latches an external interrupt input on the XINT pin(s). The callback is dispatched with the following parameters, respectively:

  • application-provided callback parameter (pCBParam),
  • the interrupt ID (ADI_XINT_EVENT) that initiated the interrupt,
  • NULL.
Parameters
[in]eEventThe interrupt for which the callback is being registered.
[in]pfCallbackPointer to the callback function. This can be passed as NULL to unregister the callback.
[in]pCBParamCallback parameter which will be passed back to the application when the callback is called..
Returns
Status
See also
adi_xint_EnableIRQ
adi_xint_DisableIRQ

Definition at line 333 of file adi_xint.c.