Exemple #1
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();
}
Exemple #2
0
/*********************************************************************
*
*       IP_Log
*
*  Function description
*    This function is called by the stack in debug builds with log output.
*    In a release build, this function may not be linked in.
*
*  Notes
*    (1)  Interrupts and task switches
*         printf() has a reentrance problem on  alot of systems if interrupts are not disabled.
*                  which would scramble strings if printf() called from an ISR interrupts an other printf.
*         In order to avoid this problem, interrupts are disabled.
*
*/
void IP_Log(const char * s) {

  IP_OS_DisableInterrupt();
  _ShowStamp();
  _puts(s);
  _puts("\n");
  IP_OS_EnableInterrupt();
}
Exemple #3
0
/*********************************************************************
*
*       IP_Warn
*
*  Function description
*    This function is called by the stack in debug builds with log output.
*    In a release build, this function may not be linked in.
*
*  Notes
*    (1)  Interrupts and task switches
*         See IP_Log()
*/
void IP_Warn(const char * s) {
  IP_OS_DisableInterrupt();
  _ShowStamp();
  _puts("*** Warning *** ");
  _puts(s);
  _puts("\n");
  IP_OS_EnableInterrupt();
}
Exemple #4
0
/*********************************************************************
*
*       IP_Panic
*
*  Function description
*    This function is called if the stack encounters a critical situation.
*    In a release build, this function may not be linked in.
*
*/
void IP_Panic(const char * s) {
  (void)s;
  IP_OS_DisableInterrupt();
#if IP_DEBUG > 1
  _puts("*** Fatal error, System halted: ");
  _puts(s);
  _puts("\n");
#endif
  while (1);
}