コード例 #1
0
/**
 * \brief Set an interrupt handler for the specified pin.
 * The provided handler will be called with the triggering pin as its parameter
 * as soon as an interrupt is detected.
 *
 * \param ul_pin Pin index to configure.
 * \param ul_flag Pin flag.
 * \param p_handler Interrupt handler function pointer.
 *
 * \return 0 if successful, 1 if the maximum number of sources has been defined.
 */
uint32_t pio_handler_set_pin(uint32_t ul_pin, uint32_t ul_flag,
		void (*p_handler) (uint32_t, uint32_t))
{
	Pio *p_pio = pio_get_pin_group(ul_pin);
	uint32_t group_id =  pio_get_pin_group_id(ul_pin);
	uint32_t group_mask = pio_get_pin_group_mask(ul_pin);

	return pio_handler_set(p_pio, group_id, group_mask, ul_flag, p_handler);
}
コード例 #2
0
void Gpio::enableInterrupt(IGpio_Callback_t callback, void *user) {
    int groupIndex = groupId2groupIndex(pio_get_pin_group_id(_pin));

    if (groupIndex < 0) {
        return;
    }

    _callback[groupIndex][_pin] = callback;
    _user[groupIndex][_pin]     = user;

    // Todo:
    // pio_handler_set_pin(_pin, (PIO_PULLUP | PIO_DEBOUNCE | PIO_IT_RISE_EDGE), staticISR);
    pio_handler_set_pin(_pin, PIO_IT_FALL_EDGE, staticISR);
    pio_enable_pin_interrupt(_pin);
}