MCP23008-RK
Data Fields
MCP23008InterruptHandler Struct Reference

Internal structure used to hold information about configured interrupts. More...

#include <MCP23008-RK.h>

Data Fields

uint16_t pin
 The MCP23008 pin (0-7)
 
InterruptMode mode
 The interrupt mode, one of: More...
 
std::function< void(bool)> handler
 The interrupt handler function or C++11 lambda function. More...
 
bool lastState
 The last state of the GPIO, used to handle the RISING and FALLing cases.
 

Detailed Description

Internal structure used to hold information about configured interrupts.

Use attachInterrupt() to add an interrupt handler, which internally creates one of these structures.

Field Documentation

◆ handler

std::function<void(bool)> MCP23008InterruptHandler::handler

The interrupt handler function or C++11 lambda function.

It has this prototype:

void hander(bool newState);

The newState parameter is the state of the pin after the change that caused the interrupt. For a RISING interrupt, for example, newState will always be true.

◆ mode

InterruptMode MCP23008InterruptHandler::mode

The interrupt mode, one of:

  • RISING
  • FALLING
  • CHANGE

These are the same constants used with the Device OS attachInterrupt call.

Because the MCP23008 handles rising and falling in a peculiar way that's different than the STM32 and nRF52 MCUs, the hardware is always configured as change. The rising and falling cases are generated in software in this library.


The documentation for this struct was generated from the following file: