EINT

The External Interrupt API allows the user to configure how the external interrupts pins trigger IRQs.

The following is an example of how to use the EINT in an OS environment:

#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
#include "mcu/mcu.h"

void my_eint_action(void * context, uint32_t value){
     //take some action on an eint event -- this runs in priveleged, handler mode, it should be fast and short
}

int configure_eint(){
     int fd;
     eint_attr_t attr;
     eint_action_t action;

     fd = open("/dev/eint0", O_RDWR);
     if ( fd < 0 ){
          printf("Error opening peripheral (%d)\n", errno);
     } else {
     attr.pin_assign = 0;
          if( ioctl(fd, I_SETATTR, &ctl) < 0 ){
               printf("Failed to set peripheral configuration (%d)\n", errno);
               return -1;
     }

     //Now set an action to take when a falling edge occurs on eint0
     action.channel = 0; //unused
     action.o_events = EINT_ACTION_EVENT_FALLING; //no events are defined for the EINT
     action.handler.callback = my_eint_action;
     action.handler.context = NULL;
     if ( ioctl(fd, I_SETACTION, &action) ){
          printf("Error setting action for peripheral (%d)\n", errno);
          return -1;
     }

     }
     close(fd);
     return 0;
}

Details

define EINT_VERSION

define EINT_IOC_IDENT_CHAR

define I_EINT_GETVERSION

define I_EINT_GETINFO

define I_EINT_SETATTR

define I_EINT_SETACTION

This sets the action for an EINT channel. For example:

mcu_action_t action;
action.channel = 0; //channel if used on the architecture
action.handler.callback = my_callback; //function to execute when event happens
action.handler.context = NULL;  //passed to action.handler.callback as first argument
action.o_events = EINT_ACTION_EVENT_RISING; //Trigger on rising edge
ioctl(eint_fd, I_EINT_SETACTION, &action);

define I_EINT_TOTAL

enum @10
  • EINT_FLAG_NONE
  • EINT_FLAG_SET_INPUT

struct::eint_info_t

u32 o_flags

Bitmask of supported attributes

u32 value

Value of the pin (zero or non-zero)

u32 resd

struct::eint_pin_assignment_t

mcu_pin_t channel

u32 resd

struct::eint_attr_t

This data structure is used for controlling external interrupt IO peripherals.

u32 o_flags

Set the attibutes (use PIO_FLAG values)

eint_pin_assignment_t pin_assignment

X

Thanks for Coming!

Subscribe to news and updates