group::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

defineEINT_VERSION


defineEINT_IOC_IDENT_CHAR


defineI_EINT_GETVERSION


defineI_EINT_GETINFO


defineI_EINT_SETATTR


defineI_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);

defineI_EINT_TOTAL


enum@11

  • EINT_FLAG_NONE
  • EINT_FLAG_SET_INPUT


date: “2019-06-27” layout: post title: struct::eint_info_t katex: true

categories: struct

Methods

Details

public u32o_flags

Bitmask of supported attributes


public u32value

Value of the pin (zero or non-zero)


public u32resd



date: “2019-06-27” layout: post title: struct::eint_pin_assignment_t katex: true

categories: struct

Methods

Details

publicmcu_pin_tchannel


public u32resd



date: “2019-06-27” layout: post title: struct::eint_attr_t katex: true

categories: struct

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

Methods

Details

public u32o_flags

Set the attibutes (use PIO_FLAG values)


public eint_pin_assignment_tpin_assignment


X

Thanks for Coming!

Subscribe to news and updates