libpynq (release 5EWC0-2023 version 0.2.1 of 2023-09-01 11:02)
Loading...
Searching...
No Matches
Interrupt library

Functions

int gpio_interrupt_init (void)
 
void gpio_ack_interrupt (void)
 
void verify_interrupt_request (const pin_t pin)
 
void gpio_print_interrupt (void)
 
void gpio_enable_interrupt (const pin_t pin)
 
void gpio_disable_interrupt (const pin_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 pin_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] == SWB_BTN0) {
printf("interrupt on SWB_BTN0, turning on SWB_LD0\n");
} else {
printf("interrupt on pin %d\n",interruptPin[0]);
}
}
gpio_destroy(void);
return EXIT_SUCCESS;
}
void gpio_set_level(const gpio_t pin, const gpio_level_t level)
Definition gpio.c:7
void gpio_set_direction(const gpio_t pin, const gpio_direction_t direction)
Definition gpio.c:5
void gpio_enable_interrupt(const gpio_t pin)
Definition interrupt.c:6
void gpio_wait_for_interrupt(const gpio_t pin)
Definition interrupt.c:11
void gpio_reset(void)
Reset all GPIO pins.
Definition gpio.c:18
void gpio_destroy(void)
Definition gpio.c:3
void gpio_init(void)
Definition gpio.c:2
@ GPIO_DIR_OUTPUT
Definition gpio.h:85
uint8_t * gpio_get_interrupt_pins(uint8_t *positions)
Gets all pins on which an interrupt occurred.
Definition interrupt.c:10
int gpio_interrupt_init(void)
Enables interrupts to be set and read.
Definition interrupt.c:2
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
@ SWB_BTN0
Button input pins.
Definition pinmap.h:83
@ SWB_LD0
LED output pins.
Definition pinmap.h:91
void switchbox_destroy(void)
Resets all pins of the switch box to be input.
Definition switchbox.c:6
void switchbox_reset(void)
Resets all pins of the switch box to be input.
Definition switchbox.c:5
void switchbox_init(void)
Initializes the switch box.
Definition switchbox.c:3

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 pin_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 72 of file interrupt.c.

Here is the call graph for this function:

◆ gpio_enable_interrupt()

void gpio_enable_interrupt ( const pin_t  pin)

enables a specific pin to raise interrupts.

Parameters
pinto raise interrupts

Definition at line 59 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 pin_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 138 of file interrupt.c.

Here is the call graph for this function:

◆ verify_interrupt_request()

void verify_interrupt_request ( const pin_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 96 of file interrupt.c.