libpynq  (release 5EID0-2023 version 0.3.0 of 2024-04-25 09:42 )
Interrupt library

Functions

int gpio_interrupt_init (void)
 
void gpio_ack_interrupt (void)
 
void verify_interrupt_request (const io_t pin)
 
void gpio_print_interrupt (void)
 
void gpio_enable_interrupt (const io_t pin)
 
void gpio_disable_interrupt (const io_t pin)
 
void gpio_disable_all_interrupts (void)
 
uint64_t gpio_get_interrupt (void)
 
uint8_t * gpio_get_interrupt_pins (uint8_t *positions)
 
void gpio_wait_for_interrupt (const io_t pin)
 

Detailed Description

Functions for interrupt handling.

An example of using this library

#include <libpynq.h>
int main (void)
{
gpio_init(void);
gpio_reset(void);
// initialize the interrupt
while(1) {
gpio_wait_for_interrupt(64); //Wait untill an interupt arrives
uint8_t* interruptPin = gpio_get_interrupt_pins(void);
if (interruptPin[0] == IO_BTN0) {
printf("interrupt on IO_BTN0, turning on IO_LD0\n");
} else {
printf("interrupt on pin %d\n",interruptPin[0]);
}
}
gpio_destroy(void);
return EXIT_SUCCESS;
}

Function Documentation

◆ gpio_ack_interrupt()

void gpio_ack_interrupt ( void  )

acknowledges the raised interrupts and resets the interrupt word. Allows new interrupts to occur on the previously triggered pins.

Definition at line 3 of file interrupt.c.

Here is the call graph for this function:

◆ gpio_disable_all_interrupts()

void gpio_disable_all_interrupts ( void  )

Disables all interrupts from being raised.

Definition at line 8 of file interrupt.c.

Here is the call graph for this function:

◆ gpio_disable_interrupt()

void gpio_disable_interrupt ( const io_t  pin)

Disables interrupts from occuring on the specific pin. Hereafter, the pin will not trigger an interrupt.

Parameters
pinto be disabled from obtianing interrupts

Definition at line 7 of file interrupt.c.

Here is the call graph for this function:

◆ gpio_enable_interrupt()

void gpio_enable_interrupt ( const io_t  pin)

enables a specific pin to raise interrupts.

Parameters
pinto raise interrupts

Definition at line 6 of file interrupt.c.

Here is the call graph for this function:

◆ gpio_get_interrupt()

uint64_t gpio_get_interrupt ( void  )
Returns
the 64 bits on which interrupts are indicated by a one. The bits are in accordance with the pins described in pinmap.h

Definition at line 9 of file interrupt.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gpio_get_interrupt_pins()

uint8_t* gpio_get_interrupt_pins ( uint8_t *  positions)

Gets all pins on which an interrupt occurred.

Returns
a pointer to an array of maximum 64 intergers. The integers correspond to pins with a pending interrupt.

Definition at line 10 of file interrupt.c.

Here is the call graph for this function:

◆ gpio_interrupt_init()

int gpio_interrupt_init ( void  )

Enables interrupts to be set and read.

Definition at line 2 of file interrupt.c.

◆ gpio_print_interrupt()

void gpio_print_interrupt ( void  )

prints the current interrupt word

Definition at line 5 of file interrupt.c.

Here is the call graph for this function:

◆ gpio_wait_for_interrupt()

void gpio_wait_for_interrupt ( const io_t  pin)

Waits untill an interrupt occurs on the specified pin or if the value of pin is larger than 63, if any interrupt has occurred.

Parameters
pinThe pin on which an interrupt should occur

Definition at line 11 of file interrupt.c.

Here is the call graph for this function:

◆ verify_interrupt_request()

void verify_interrupt_request ( const io_t  pin)

Checks for error in enabled pin. Terminates the process if the pin is not enabled.

Parameters
pinindicates a specific pin or if larger than 63, if any interrupt pin is enabled

Definition at line 4 of file interrupt.c.

Here is the caller graph for this function:
gpio_get_interrupt_pins
uint8_t * gpio_get_interrupt_pins(uint8_t *positions)
Gets all pins on which an interrupt occurred.
Definition: interrupt.c:10
GPIO_DIR_OUTPUT
@ GPIO_DIR_OUTPUT
Definition: gpio.h:92
gpio_set_level
void gpio_set_level(const io_t pin, const gpio_level_t level)
Set the level of the output IO pin. If the pin is configured as input, this function does nothing.
Definition: gpio.c:7
gpio_ack_interrupt
void gpio_ack_interrupt(void)
acknowledges the raised interrupts and resets the interrupt word. Allows new interrupts to occur on t...
Definition: interrupt.c:3
switchbox_init
void switchbox_init(void)
Initializes the switch box.
Definition: switchbox.c:3
gpio_set_direction
void gpio_set_direction(const io_t pin, const gpio_direction_t direction)
Set the IO pin as in input or output.
Definition: gpio.c:5
switchbox_reset
void switchbox_reset(void)
Resets all pins of the switch box to be input.
Definition: switchbox.c:5
gpio_wait_for_interrupt
void gpio_wait_for_interrupt(const io_t pin)
Waits untill an interrupt occurs on the specified pin or if the value of pin is larger than 63,...
Definition: interrupt.c:11
gpio_init
void gpio_init(void)
Definition: gpio.c:2
gpio_reset
void gpio_reset(void)
Reset all IO pins.
Definition: gpio.c:18
gpio_enable_interrupt
void gpio_enable_interrupt(const io_t pin)
enables a specific pin to raise interrupts.
Definition: interrupt.c:6
IO_BTN0
@ IO_BTN0
Button input pins.
Definition: pinmap.h:83
gpio_interrupt_init
int gpio_interrupt_init(void)
Enables interrupts to be set and read.
Definition: interrupt.c:2
switchbox_destroy
void switchbox_destroy(void)
Resets all pins of the switch box to be input.
Definition: switchbox.c:6
IO_LD0
@ IO_LD0
LED output pins.
Definition: pinmap.h:91
gpio_destroy
void gpio_destroy(void)
Definition: gpio.c:3
libpynq.h