[zynq] Add support for GPIO interrupts

This commit is contained in:
Christopher Anderson
2015-04-23 12:04:44 -07:00
parent fdecb22f2e
commit 4a038ceef6
5 changed files with 161 additions and 9 deletions

View File

@@ -24,4 +24,6 @@
/* gpios on the zybo target */
#define GPIO_LEDY (7)
#define ZYBO_BTN4 (50)
#define ZYBO_BTN5 (51)

View File

@@ -28,6 +28,8 @@
#include <kernel/vm.h>
#include <platform/zynq.h>
#include <platform/gem.h>
#include <platform/gpio.h>
#include <platform/interrupts.h>
#include <target/gpioconfig.h>
#define ZYNQ_PKTBUF_CNT 128
@@ -186,6 +188,21 @@ void target_early_init(void)
gpio_set(GPIO_LEDY, 0);
}
static enum handler_return toggle_ledy(void *arg) {
static bool on = false;
gpio_set(GPIO_LEDY, on);
on = !on;
return INT_NO_RESCHEDULE;
}
void target_set_debug_led(unsigned int led, bool on)
{
if (led == 0) {
gpio_set(GPIO_LEDY, on);
}
}
void target_init(void)
{
paddr_t buf_vaddr;
@@ -210,12 +227,9 @@ void target_init(void)
pktbuf_create_bufs((void *)buf_vaddr, ZYNQ_PKTBUF_CNT * sizeof(pktbuf_buf_t));
gem_init(GEM0_BASE);
register_gpio_int_handler(ZYBO_BTN5, toggle_ledy, NULL);
zynq_unmask_gpio_interrupt(ZYBO_BTN5);
}
void target_set_debug_led(unsigned int led, bool on)
{
if (led == 0) {
gpio_set(GPIO_LEDY, on);
}
}