Нужно обработать прерывания от него.
Делаем все по учебнику:
Код
static void handle_button_interrupts(void* context, alt_u32 id) {
СЮДА ХОТЕЛОСЬ БЫ ПОПАСТЬ
/* cast the context pointer to an integer pointer. */
volatile int* edge_capture_ptr = (volatile int*) context;
/*
* Read the edge capture register on the button PIO.
* Store value.
*/
*edge_capture_ptr = IORD_ALTERA_AVALON_PIO_EDGE_CAP(PIO_2_BASE);
/* Write to the edge capture register to reset it. */
IOWR_ALTERA_AVALON_PIO_EDGE_CAP(PIO_2_BASE, 0);
/* reset interrupt capability for the Button PIO. */
IOWR_ALTERA_AVALON_PIO_IRQ_MASK(PIO_2_BASE, 0xff);
}
// Настройка прерывания от PIO_2
static void init_button_pio() {
/* Recast the edge_capture pointer to match the
alt_irq_register() function prototype. */
void* edge_capture_ptr = (void*) &edge_capture;
/* Enable all 4 button interrupts. */
IOWR_ALTERA_AVALON_PIO_IRQ_MASK(PIO_2_BASE, 0xff);
/* Reset the edge capture register. */
IOWR_ALTERA_AVALON_PIO_EDGE_CAP(PIO_2_BASE, 0x0);
/* Register the ISR. */
alt_irq_register(PIO_2_IRQ, edge_capture_ptr, handle_button_interrupts);
}
СЮДА ХОТЕЛОСЬ БЫ ПОПАСТЬ
/* cast the context pointer to an integer pointer. */
volatile int* edge_capture_ptr = (volatile int*) context;
/*
* Read the edge capture register on the button PIO.
* Store value.
*/
*edge_capture_ptr = IORD_ALTERA_AVALON_PIO_EDGE_CAP(PIO_2_BASE);
/* Write to the edge capture register to reset it. */
IOWR_ALTERA_AVALON_PIO_EDGE_CAP(PIO_2_BASE, 0);
/* reset interrupt capability for the Button PIO. */
IOWR_ALTERA_AVALON_PIO_IRQ_MASK(PIO_2_BASE, 0xff);
}
// Настройка прерывания от PIO_2
static void init_button_pio() {
/* Recast the edge_capture pointer to match the
alt_irq_register() function prototype. */
void* edge_capture_ptr = (void*) &edge_capture;
/* Enable all 4 button interrupts. */
IOWR_ALTERA_AVALON_PIO_IRQ_MASK(PIO_2_BASE, 0xff);
/* Reset the edge capture register. */
IOWR_ALTERA_AVALON_PIO_EDGE_CAP(PIO_2_BASE, 0x0);
/* Register the ISR. */
alt_irq_register(PIO_2_IRQ, edge_capture_ptr, handle_button_interrupts);
}
Код
...
init_button_pio();
...
init_button_pio();
...
Что получается - глядим дебагером. Когда доходит до одной из функций alt_irq_ччч (к примеру alt_irq_register, а в ней alt_irq_disable_all...) получаем сообщение: "Source not found."
Что это значит, ошибка где? Все что не касается прерываний этого PIO работает нормально...