34#define DOMAIN "Interrupt"
37extern uint32_t *
intc0;
39static bool gpio_initialized =
false;
42 if (gpio_initialized ==
false) {
43 pynq_error(
"Interrupts have not been initialized. Call "
44 "gpio_interupt_init() first.\n");
49 int fd = open(
"/dev/uio1", O_RDWR, O_CLOEXEC);
55 gpio_initialized =
true;
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];
99 uint64_t retv =
intc0[1];
103 uint64_t bitMask = 1ULL <<
pin;
104 if (!(bitMask & retv)) {
105 pynq_error(
"Pin %d is not enabled. Enable by using "
106 "gpio_enable_interrupt(pin). \n",
111 pynq_error(
"No interrupts enabled. Enable by using "
112 "gpio_enable_interrupt(pin). \n");
122 printf(
"interrupt 0: %08X %08X\r\n",
intc0[0],
intc0[2]);
123 printf(
"interrupt 1: %08X %08X\r\n",
intc0[1],
intc0[3]);
131 positions[count++] = index;
144 if (interrupt != 0) {
151 uint64_t bitMask = 1ULL <<
pin;
152 if (bitMask & interrupt) {
164 uint64_t
pin = (uint64_t)((uint64_t)(
intc0[3]) << 32 |
intc0[2]);
168 for (
int i = 0; i < 64; i++) {
169 if (positions[i] != 0) {
176 printf(
"WARNING: gpio_get_interrupt_pins: No pins interrupted. ");
void gpio_enable_interrupt(const gpio_t pin)
void gpio_disable_interrupt(const gpio_t pin)
void gpio_wait_for_interrupt(const gpio_t pin)
void verify_interrupt_request(const gpio_t pin)
void gpio_disable_all_interrupts(void)
Disables all interrupts from being raised.
uint8_t * gpio_get_interrupt_pins(uint8_t *positions)
Gets all pins on which an interrupt occurred.
int gpio_interrupt_init(void)
Enables interrupts to be set and read.
uint64_t gpio_get_interrupt(void)
void gpio_print_interrupt(void)
prints the current interrupt word
void gpio_ack_interrupt(void)
acknowledges the raised interrupts and resets the interrupt word. Allows new interrupts to occur on t...
void sleep_msec(int msec)
Wait for msec milliseconds.
void check_initialization(void)
void findSetBitPositions(uint64_t word, uint8_t *positions)