Page 1 of 1

Events for PAL driver?

Posted: Sat Aug 31, 2013 12:46 am
by Fuentes
Hi everyone.

I'm newbie in ChibiOS, and i got a little question for the community.
I trying to figure out how i can listen for events when a button is pressed, connected to a digital input pin, instead of permanently poll the status of that pin.

I found this code using the poll method:

Code: Select all

static WORKING_AREA(waThread1, 32);
static msg_t Thread1(void *arg) {

  while (TRUE) {
    if (!palReadPad(IOPORT1, PORTA_BUTTON2))
      palTogglePad(IOPORT1, PORTA_RELAY);
    chThdSleepMilliseconds(1000);
  }
  return 0;
}


Is there a way to use the Events infrastucture offered by ChibiOS?
Just in case: I'm using this (https://code.google.com/p/rtoslibs/) Arduino port with a Leonardo board.

Many thx in advance.

Re: Events for PAL driver?

Posted: Sat Aug 31, 2013 7:25 am
by Giovanni
Hi,

Look at the EXT or ICU drivers, you can broadcast events from callbacks. Alternatively you can poll pins using a thread or a virtual timer.

Giovanni