Exemplo n.º 1
0
/**********************************************************
*
*       USB_OS_Init
*
*/
void USB_OS_Init(void) {
  unsigned i;

  for (i = 0; i < COUNTOF(_aEvent); i++) {
    OS_EVENT_Create(&_aEvent[i]);
  }
}
Exemplo n.º 2
0
bool_t osCreateEvent(OsEvent *event)
{
   //Create an event object
   OS_EVENT_Create(event);

   //The event object was successfully created
   return TRUE;
}
Exemplo n.º 3
0
/*********************************************************************
*
*       _StatusTask
*
*/
static void _StatusTask(void) {
  static USB_HOOK  _Hook;

  OS_EVENT_Create(&_Event);
  USB_RegisterSCHook(&_Hook, _OnStatusChange, &_Data32, sizeof(_Data32));
  while(1) {
    printf("Current state = %s %s %s %s %s\n", (_State & USB_STAT_ATTACHED)  ? "Attached  " : "",
                                               (_State & USB_STAT_READY)     ? "Ready     " : "",
                                               (_State & USB_STAT_ADDRESSED) ? "Addressed " : "",
                                               (_State & USB_STAT_CONFIGURED)? "Configured" : "",
                                               (_State & USB_STAT_SUSPENDED) ? "Suspended " : ""
                                           );
    OS_EVENT_Wait(&_Event);
  }
}
Exemplo n.º 4
0
/*********************************************************************
*
*       IP_OS_WaitItemTimed()
*
*  Function description
*    Suspend a task which needs to wait for a object.
*    This object is identified by a pointer to it and can be of any type, e.g. socket.
*
*  Context
*    Function is called from an application task.
*/
void IP_OS_WaitItemTimed(void * pWaitItem, unsigned Timeout) {
  TCP_WAIT TCPWait;

  //
  // Create the wait object which contains the OS-Event object
  //
  TCPWait.pPrev     = NULL;
  TCPWait.pWaitItem = pWaitItem;
  OS_EVENT_Create(&TCPWait.Event);
  //
  // Add to doubly-linked list with temp. disabled interrupts
  //
  IP_OS_DisableInterrupt();
  TCPWait.pNext = _pTCPWait;
  _pTCPWait = &TCPWait;
  if (TCPWait.pNext) {
    TCPWait.pNext->pPrev = &TCPWait;
  }
  IP_OS_EnableInterrupt();
  //
  // Unlock mutex and suspend this task
  //
  IP_OS_Unlock();
  if (Timeout == 0) {
    OS_EVENT_Wait(&TCPWait.Event);
  } else {
    OS_EVENT_WaitTimed(&TCPWait.Event, Timeout);
  }
  //
  // Remove it from doubly linked list with temp. disabled interrupts
  //
  IP_OS_DisableInterrupt();
  if (TCPWait.pPrev) {
    TCPWait.pPrev->pNext = TCPWait.pNext;
  } else {
    _pTCPWait = TCPWait.pNext;
  }
  if (TCPWait.pNext) {
    TCPWait.pNext->pPrev = TCPWait.pPrev;
  }
  IP_OS_EnableInterrupt();
  //
  // Delete the event object & lock the mutex again
  //
  OS_EVENT_Delete(&TCPWait.Event);
  IP_OS_Lock();
}
Exemplo n.º 5
0
/**********************************************************
*
*       IP_OS_Init
*
*  Function description
*    Initialize (create) all objects required for task syncronisation.
*    These are 2 events (for IP_Task and RxTask)
*    and one semaphore for protection of critical code which  may not be
*    executed from multiple task at the same time.
*/
void IP_OS_Init(void) {
  OS_EVENT_Create(&_EventNet);
  OS_EVENT_Create(&_EventRx);
  OS_CREATERSEMA(&_Lock);
}