Events for PAL driver?

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
Fuentes
Posts: 1
Joined: Sat Aug 31, 2013 12:28 am

Events for PAL driver?

Post 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.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Events for PAL driver?

Post 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
Post Reply