34#define DOMAIN "Interrupt"
37extern uint32_t *
intc0;
39static bool started =
false;
42 if (started ==
false) {
43 pynq_error(
"Interrupts are not initialized. Use gpio_interupt_init() to "
44 "initialize these. \n");
49 int fd = open(
"/dev/uio1", O_RDWR, O_CLOEXEC);
61 int pin_bank =
pin % 32;
62 int bank =
pin < 32 ? 0 : 1;
64 printf(
"interrupt set 0: %08X %08X\r\n",
pin, pin_bank);
65 intc0[0] |= (1 << pin_bank);
67 printf(
"interrupt set 1: %08X %08X\r\n",
pin, pin_bank);
68 intc0[1] |= (1 << (pin_bank));
85 uint64_t retv =
intc0[3];
103 uint64_t retv =
intc0[1];
107 uint64_t bitMask = 1ULL <<
pin;
108 if (!(bitMask & retv)) {
109 pynq_error(
"Pin %d is not enabled. Enable by using "
110 "gpio_enable_interrupt(pin). \n",
115 pynq_error(
"No interrupts enabled. Enable by using "
116 "gpio_enable_interrupt(pin). \n");
126 printf(
"interrupt 0: %08X %08X\r\n",
intc0[0],
intc0[2]);
127 printf(
"interrupt 1: %08X %08X\r\n",
intc0[1],
intc0[3]);
135 positions[count++] = index;
148 if (interrupt != 0) {
155 uint64_t bitMask = 1ULL <<
pin;
156 if (bitMask & interrupt) {
168 uint64_t
pin = (uint64_t)((uint64_t)(
intc0[3]) << 32 |
intc0[2]);
172 for (
int i = 0; i < 64; i++) {
173 if (positions[i] != 0) {
180 printf(
"WARNING: gpio_get_interrupt_pins: No pins interrupted. ");
void gpio_enable_interrupt(const gpio_t pin)
enables a specific pin to raise interrupts.
uint64_t gpio_get_interrupt(void)
uint8_t * gpio_get_interrupt_pins()
void gpio_disable_interrupt(const gpio_t pin)
Disables interrupts from occuring on the specific pin. Hereafter, the pin will not trigger an interru...
void gpio_print_interrupt(void)
prints the current interrupt word
void gpio_disable_all_interrupts(void)
Disables all interrupts from being raised.
void gpio_ack_interrupt(void)
acknowledges the raised interrupts and resets the interrupt word. Allows new interrupts to occur on t...
int gpio_interrupt_init(void)
Enables interrupts to be set and read.
void gpio_wait_for_interrupt(const gpio_t pin)
Waits untill an interrupt occurs on the specified pin or if the value of pin is larger than 63,...
void verify_interrupt_request(const gpio_t pin)
Checks for error in enabled pin. Terminates the process if the pin is not enabled.
void sleep_msec(int msec)
Wait for msec milliseconds.
void check_initialization(void)
void findSetBitPositions(uint64_t word, uint8_t *positions)