01.06.2013 Views

IPC@CHIP Documentation - SC12 @CHIP-RTOS V1.10

IPC@CHIP Documentation - SC12 @CHIP-RTOS V1.10

IPC@CHIP Documentation - SC12 @CHIP-RTOS V1.10

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

within the ISR.<br />

With API call DEV_NOTIFY_ISR the ISR should wakeup a user provided task, which receives the incoming data<br />

from the device and moves the data into the TCP/IP stack. This task should use API call DEV_RECV_WAIT and<br />

DEV_RECV_IFACE (see example below).<br />

Instead of a creating a new task, it is also possible to use your program's main thread for receiving by having it<br />

perform the MyReceiveTask() actions shown below.<br />

If your device doesn't support interrupts, you could create a polling task (or again, simply use your program's main<br />

thread for this purpose) which periodically checks your device for incoming data as illustrated in the<br />

MyReceiveTask_Polling example below.<br />

Important : An ISR must be installed as a <strong>RTOS</strong> ISR with the Install Interrupt Service Routine of the Hardware<br />

API.<br />

Generic examples for an ISR and a two forms of receiver task functions follow.<br />

// Interrupt Service Routine<br />

void interrupt MyDeviceISRHandler(void)<br />

{<br />

int receivedFrames;<br />

int errorCode;<br />

}<br />

// Hardware specific: Check if there are incoming data packets available<br />

// Wakeup receiver task<br />

Dev_Notify_ISR(MyDevHandle, receivedFrames, 0, &errorCode); // C-Lib call<br />

// Note: Issue no EOI here.<br />

// (EOI for the ISR is issued inside of the CHIP-<strong>RTOS</strong>.)<br />

// Generic example for a receiver task function, which waits for an event from ISR:<br />

void huge MyReceiveTask(void)<br />

{<br />

int errorCode;<br />

int statRecv;<br />

// Optional: do some initialization<br />

}<br />

while(1)<br />

{<br />

// Wait for a wakeup from ISR<br />

Dev_Recv_Wait(mydevdriver.IfaceHandle, &errorCode); // C-Lib call<br />

}<br />

// After wakeup received and move incoming data into the stack<br />

do<br />

{ // C-Lib call<br />

statRecv = Dev_Recv_Interface(mydevdriver.IfaceHandle, &errorCode);<br />

} while (statRecv != -1);<br />

// Generic example for receiver task, polling for incoming data:<br />

void huge MyReceiveTask_Polling(void)<br />

{<br />

int errorCode;<br />

// Optional: do some initialization<br />

// Wait for completion of interface installation (Intr 0xAC 0xA0)<br />

while (install_done == 0)<br />

{<br />

RTX_Sleep_Time(10); // Go to sleep for a defined time.<br />

Page 348 / 400

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

Saved successfully!

Ooh no, something went wrong!