class hal::Eint
  : public hal::Periph< eint_info_t, eint_attr_t, EintAttributes, 'e'>

This class gives access to external interrupt circuitry. You can use this class to have the interrupt trigger a function or block a thread until the interrupt arrives.

Here is an example:

#include <sapi/hal.hpp>
#include <sapi/sys.hpp>

 //This will be executed when the event is triggered
int event_callback(void * args, const void * data){
   volatile int * done = (int*)args;
   *done = 1;
   return 0; //return 0 to clear the callback and 1 to keep it

void eint_example(){
   volatile int done;
   Eint eint(0); //use eint port 0 (pin 2.10 on lpc17xx devices)

   eint.init(); //open and set attributes

   eint.set_action(0, //use channel 0
      EINT_ACTION_EVENT_FALLING, //trigger on a falling edge
      event_callback, //execute this function (in privileged mode when complete)
      &done //pass this to event_callback as the first argumen

   while( done == 0 ){
      Timer::wait_milliseconds(1); //wait for the signal to arrive


 //alternatively you can configure (set_action() and block by writing hwpl_action_t to the device)

 mcu_action_t action; = 0;
 action.callback = 0; //this is ignored and doesn't need to be set
 action.context = 0; //this is ignored and doesn't need to be set
 eint.write(&action, sizeof(action)); //this will block until a falling edge arrives



port_t port

bool get_value()



port_t port

bool get_value()

Reads the value of the pin


Thanks for Coming!

Subscribe to news and updates