Handle GIO pin interrupt of TelosB with Contiki-OS

424 views Asked by At

I am trying to read an external button interrupt in Telosb. I am using GIO2 to read the interrupt, and it works quite nice with polling techniques, but I am looking something closer to an actual interrupt method.

Referring to TinyOS, there was a HplMsp430Interrupt interface that one could implement for that purpose. I cannot find something similar in Contiki-OS.

Changing pin status does not seem to fire any events, as PROCESS_WAIT_EVENTdoes not respond.

1

There are 1 answers

1
kfx On

A driver for the button on TelosB is already implemented in Contiki. There is no need to work at the interrupt handler level to use it, just call the Contiki API:

#include "dev/button-sensor.h" 

PROCESS_THREAD(app_Process, ev, data)
{
    PROCESS_BEGIN();

    SENSORS_ACTIVATE(button_sensor);

    for(;;) {
        PROCESS_WAIT_EVENT();
        if (ev == sensors_event && data == &button_sensor) {
            puts("button clicked");
        }
    }
}

If you're talking about something else and actually need to implement you own interrupt handler, then Contiki will not help you much. For some Contiki platforms there are macros or functions for controlling GPIO pins, but not for msp430. So you just need to use the I/O port interface from the compiler headers, and declare interrupt handler functions with ISR(PORT_NUMBER, function_name), where PORT_NUMBER is PORT1 or PORT2 (a port that supports interrupt handlers).

See contiki/cpu/msp430/button.c for an example how the TelosB button interrupt handler is implemented, it's pretty simple.