02.01.2015 Views

CooCox CoOS User's Guide

CooCox CoOS User's Guide

CooCox CoOS User's Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Example usage:<br />

#include "CCRTOS.h"<br />

void EXTI0_IRQHandler(void)<br />

{<br />

CoEnterISR(); // Enter ISR<br />

…<br />

/* Process interrupt here */<br />

…<br />

CoExitISR(); // Exit ISR<br />

}<br />

Note:<br />

1) When the system API functions are called in the ISR, you need to start<br />

a task scheduling by calling CoExitISR().<br />

2) When the system exits the interrupts, decrease the interrupt nesting<br />

counter- OSIntNesting by one. When OSIntNesting reaches 0, start<br />

task scheduling.<br />

3) CoExitISR() and CoEnterISR() must be used in pairs.<br />

6.1.5 CoSchedLock()<br />

Function Prototype:<br />

void CoSchedLock(void);<br />

Descriptions:<br />

Lock the scheduler.<br />

Parameters:<br />

None<br />

Returns:<br />

None<br />

Example usage:<br />

#include "CCRTOS.c"<br />

void Task0 (void *pdata)<br />

{<br />

.....<br />

CoSchedLock();<br />

…..<br />

/* Process critical resources here */<br />

…..<br />

CoSchedUnlock();<br />

.....<br />

}<br />

Note:<br />

1) Increase OSSchedLock by one. When the task scheduler is locked, the<br />

system ensure that the current task can’t be preempted by any other<br />

44

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

Saved successfully!

Ooh no, something went wrong!