示例#1
0
/*
 * IRQ setup:
 * Trigger an interrupt whenever a button is depressed.
 */
static void irq_setup(void)
{
	const u32 btnpins = USR_SW1 | USR_SW2;
	/* Configure interrupt as edge-sensitive */
	GPIO_IS(GPIOF) &= ~btnpins;
	/* Interrupt only respond to rising or falling edge (single-edge) */
	GPIO_IBE(GPIOF) &= ~btnpins;
	/* Trigger interrupt on rising-edge (when button is depressed) */
	GPIO_IEV(GPIOF) |= btnpins;
	/* Finally, Enable interrupt */
	GPIO_IM(GPIOF) |= btnpins;
	/* Enable the interrupt in the NVIC as well */
	nvic_enable_irq(NVIC_GPIOF_IRQ);
}
示例#2
0
/**
 * \brief Disable interrupts on specified GPIO pins
 *
 * Disable interrupts on the specified GPIO pins
 *
 * Note that the NVIC must be enabled and properly configured for the interrupt
 * to be routed to the CPU.
 *
 * @param[in] gpioport GPIO block register address base @ref gpio_reg_base
 * @param[in] gpios @ref gpio_pin_id. Pins whose interrupts to disable. Any
 *		    combination of pins may be specified by OR'ing them
 *		    together.
 */
void gpio_disable_interrupts(uint32_t gpioport, uint8_t gpios)
{
	GPIO_IM(gpioport) |= gpios;
}