What mechanism is appropriate?

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

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
rew
Posts: 383
Joined: Sat Jul 19, 2014 12:59 pm
Has thanked: 2 times
Been thanked: 14 times

What mechanism is appropriate?

Post by rew »

I have an application where there are two interrupts happening, and I think I want a thread waiting for the (one of the) interrupt(s) to happen or a timeout. What is the easiest/best way to do this? Semaphores? Events? Messages? Mailboxes?
User avatar
RoccoMarco
Posts: 655
Joined: Wed Apr 24, 2013 4:11 pm
Has thanked: 83 times
Been thanked: 67 times

Re: What mechanism is appropriate?

Post by RoccoMarco »

Is it an internal or external interrupt? (in case of STM32 EXTI or NVIC)?
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: What mechanism is appropriate?

Post by Giovanni »

All the one you mentioned can be used except messages.

If you don't need to pass data then binary semaphores else mailboxes.

Giovanni
rew
Posts: 383
Joined: Sat Jul 19, 2014 12:59 pm
Has thanked: 2 times
Been thanked: 14 times

Re: What mechanism is appropriate?

Post by rew »

One is EXTI. The other is DMA done.

Is the "output" of the EXTI module not handled just like any other (NVIC) interrupt?

Regarding data. Yes there is data.... 512 bytes worth... Let's just keep that data in the buffer that we allocated for that. :-) So, for all practical purposes, there is no data to pass.

Last time I had something like this, I guessed at an appropriate mechanism, and later found out there was another one much better suited. Rewriting the existing code didn't happen.... That it CAN be done with all is not really my question. I would like a recommendation on which to use. which fits best?....

Ok. Binary semaphores it is....

UPDATE: It works! :-) Thanks.

Oh! Wait! One more thing that I need to figure out. How do I wait for the serial port output buffer to drain ?
User avatar
RoccoMarco
Posts: 655
Joined: Wed Apr 24, 2013 4:11 pm
Has thanked: 83 times
Been thanked: 67 times

Re: What mechanism is appropriate?

Post by RoccoMarco »

Is the "output" of the EXTI module not handled just like any other (NVIC) interrupt?

Yes it is. My inaccurate question was to figure out if interrupt sources was from an internal peripheral or an external pin since if you are using HAL internal IRQ are used by specific drivers. Just ignore my question.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: What mechanism is appropriate?

Post by Giovanni »

The serial driver sets events flags on various I/O conditions, buffers, errors etc.

Giovanni
Post Reply