CDC/ECM driver for mbed, based on USBDevice by mbed-official. Uses PicoTCP to access Ethernet USB device. License: GPLv2

Dependents:   USBEthernet_TEST

Fork of USB_Ethernet by Daniele Lacamera

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PicoCondition.h Source File

PicoCondition.h

00001 #ifndef __PICOMUTEX__
00002 #define __PICOMUTEX__
00003 /*
00004 * Cross-Threading Mutex Class
00005 */
00006 
00007 #include "mbed.h"
00008 #include "rtos.h"
00009 #include "Queue.h"
00010 
00011 class PicoCondition
00012 {
00013     private:
00014         Queue <int,1> * queue;
00015     public:
00016         PicoCondition()
00017         {
00018             queue = new Queue<int,1>();
00019         }
00020         
00021         ~PicoCondition()
00022         {
00023             if(queue)
00024             {
00025                 delete queue;
00026                 queue = NULL;
00027             }
00028         }
00029         
00030         bool unlock(uint32_t millisec=0,int * ptr=NULL)
00031         {
00032             osStatus status;
00033             status = queue->put(ptr, millisec);
00034             return (status == osEventMessage || status == osOK);
00035         }
00036         
00037         bool lock(uint32_t millisec=osWaitForever)
00038         {
00039             osEvent event = queue->get(millisec);
00040             return (event.status == osEventMessage || event.status == osOK);
00041         }
00042 };
00043 
00044 
00045 #endif