02.01.2015 Views

CooCox CoOS User's Guide

CooCox CoOS User's Guide

CooCox CoOS User's Guide

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.

2.7 Interrupts<br />

In <strong>CooCox</strong> <strong>CoOS</strong>, the interrupt is divided into two categories according to<br />

whether called the system API functions inside or not.<br />

For the ISR which has nothing to do with OS, <strong>CooCox</strong> <strong>CoOS</strong> does not force<br />

it to do anything and you can operate just like there is not an OS.<br />

However, for the ISR which called the system API functions inside, <strong>CooCox</strong><br />

<strong>CoOS</strong> demands that you call the relevant functions when entering or exiting the<br />

interrupt (as shown in code 8).<br />

Code 8 The interrupt handler which called the system API<br />

void WWDG_IRQHandler(void)<br />

{<br />

CoEnterISR();<br />

// Enter the interrupt<br />

isr_SetFlag(flagID); // API function<br />

..................; // Interrupt service routine<br />

}<br />

CoExitISR();<br />

// Exit the interrupt<br />

All the system API which can be called in the interrupt service routine begin<br />

with isr_, such as isr_PostSem (), isr_PostMail (), isr_PostQueueMail () and<br />

isr_SetFlag ().The calling of any other API inside the ISR will lead to the system<br />

chaos.<br />

When calling the corresponding API functions in the interrupt service<br />

routine, system need to determine whether the task scheduling is locked or not.<br />

If it is unlocked, system can call it normally. Otherwise, system will send a<br />

relevant service request to the service request list and then wait for the<br />

unlocking of the scheduler to respond it.<br />

19

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

Saved successfully!

Ooh no, something went wrong!