01.06.2013 Views

Choosing an RTOS - IAR Systems

Choosing an RTOS - IAR Systems

Choosing an RTOS - IAR Systems

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

How to choose <strong>an</strong> <strong>RTOS</strong> – ESC 2011<br />

Common features of <strong>RTOS</strong>s<br />

Hook functions (a.k.a. callback functions)<br />

For inst<strong>an</strong>ce, the debouncing of switch inputs may be more<br />

simply done by attaching a small piece of code to the periodic<br />

heartbeat function rather th<strong>an</strong> creating a separate task to<br />

perform this function.<br />

int debounce(int SampleA)<br />

{<br />

static int SampleB = 0;<br />

static int SampleC = 0;<br />

static int LastDebounceResult = 0;<br />

LastDebounceResult = LastDebounceResult &<br />

(SampleA | SampleB | SampleC) | (SampleA &<br />

SampleB & SampleC);<br />

SampleC = SampleB;<br />

SampleB = SampleA;<br />

return LastDebounceResult;<br />

}<br />

OSTimeTickHook()

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!