libpynq (release 5EWC0-2023 version 0.2.5 of 2023-10-08 10:51)
Loading...
Searching...
No Matches
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;
}
void gpio_set_direction(const io_t pin, const gpio_direction_t dir)
Set the IO pin as in input or output.
Definition gpio.c:81
void gpio_reset(void)
Reset all IO pins.
Definition gpio.c:62
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:104
void gpio_destroy(void)
Definition gpio.c:47
void gpio_init(void)
Definition gpio.c:40
@ GPIO_DIR_OUTPUT
Definition gpio.h:92
uint8_t * gpio_get_interrupt_pins(uint8_t *positions)
Gets all pins on which an interrupt occurred.
Definition interrupt.c:160
int gpio_interrupt_init(void)
Enables interrupts to be set and read.
Definition interrupt.c:48
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:138
void gpio_enable_interrupt(const io_t pin)
enables a specific pin to raise interrupts.
Definition interrupt.c:59
void gpio_ack_interrupt(void)
acknowledges the raised interrupts and resets the interrupt word. Allows new interrupts to occur on t...
Definition interrupt.c:91
@ IO_LD0
LED output pins.
Definition pinmap.h:91
@ IO_BTN0
Button input pins.
Definition pinmap.h:83
void switchbox_destroy(void)
Resets all pins of the switch box to be input.
Definition switchbox.c:112
void switchbox_reset(void)
Resets all pins of the switch box to be input.
Definition switchbox.c:118
void switchbox_init(void)
Initializes the switch box.
Definition switchbox.c:105

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 91 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 77 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 72 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 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 83 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 160 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 48 of file interrupt.c.

◆ gpio_print_interrupt()

void gpio_print_interrupt ( void  )

prints the current interrupt word

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

Here is the caller graph for this function: