ESP8266 – easy interrupts

While working on a current project i’ve faced an issue with code reuse. Espressif sdk allows only one interrupt handler for all GPIOs. That’s fine for monolithic code but since we like modular code a dispatcher comes handy.

The little inconvenience i’ve had was like this. I wanted to use the drivers/key.c code but it does use the data argument , so i’ve had to modify it to use a global variable. So i can call it from my own interrupt handler. And that is ugly.

So the lab have a brand new GitHub Account – where i’ll share code.

And the remedy for the issue –  new project: esp8266_easyintr .

May need a tweek or two.  I’ve  extracted it from a wip project.

Usage:

ei_init(); // init easy interrupts
ei_attach(GPIO_NUM, GPIO_MUX, GPIO_FUNC, module_isr, module_data); // setup  handler

You can attach only one per GPIO . You will get your data at the isr and you can have a proper code separation.

 

4 thoughts on “ESP8266 – easy interrupts”

  1. Looks nice, It is usable the code for easyIntr ? From documentation is still not clear to me how many pins can be used as GPIO ( and the number of those pins). I’ll use an ESP-201 moving from ESP-01.

    1. It’s under development yet but it’s usable. All pins that have GPIO functions can generate interrupts
      the only exception is GPIO16 which is special since it’s tied somehow to the RTC in the chip.
      How many GPIOs can be used depends on the module. I’m using ESP-07 and it have all GPIOs broken out except one which is used for
      WiFi led. Looking at the ESP-201 picture it looks similar.

  2. Hello ! I´m wondering if you could post a starting from zero guide or a link to the basic docummentation we newbies must read if we want to program the internal mcu of the esp8266 (Tensilica LX106 ?) just in assembler .
    I´ve been searching for weeks and found very little, and it seems that you can only program in C. ( I only know Basic, PIC´s and old 8bit assembler like Z80, 6502, etc). Thanks !

    1. Hi, Diego!
      There is no such thing AFAIK. Espressif supplies only C SDK. Part of this SDK is binary only. You probably can dig and find out how to link and call the functions but
      with the next release of the SDK you will have to do this again. I think you really should go with C these days. There are quite a lot of resources on the chip
      to limit yourself to assembly. And if at some point you need to use it – call it from C. But as they say – use the right tools for the job.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.