Exemplo n.º 1
0
void BPL_FreeMessageBufferFromIsr(unsigned char* pBuffer)
{
  // make sure the returned pointer is in range
  if (   pBuffer < LOW_BUFFER_ADDRESS 
      || pBuffer > HIGH_BUFFER_ADDRESS )
  {
    PrintString("Free Buffer Corruption\r\n");
    SetBufferPoolFailureBit();
  }

  signed portBASE_TYPE HigherPriorityTaskWoken;
  
  // params are: queue handle, ptr to item to queue, tick to wait if full
  // the queue can't be full unless there is a bug, so don't wait on full
  if( pdTRUE != xQueueSendFromISR(QueueHandles[FREE_QINDEX], 
                                  &pBuffer, 
                                  &HigherPriorityTaskWoken) )
  {
    PrintString("Unable to add buffer to Free Queue\r\n");
    SetBufferPoolFailureBit();
  }

#if 0
  /* this should never be true when freeing a message buffer */
  if ( HigherPriorityTaskWoken == pdTRUE )
  {
    portYIELD();
  }
#endif
  
}
Exemplo n.º 2
0
void InitializeBufferPool( void )
{
  unsigned int  ii;              // loop counter
  unsigned char* pMsgBuffer;      // holds the address of the msg buffer to add to the queue
  
  // create the queue to hold the free message buffers
  QueueHandles[FREE_QINDEX] =
    xQueueCreate( ( unsigned portBASE_TYPE ) NUM_MSG_BUFFERS,
                  ( unsigned portBASE_TYPE ) sizeof(unsigned char*) );
  
  // Add the address of each buffer's data section to the queue
  for(ii = 0; ii < NUM_MSG_BUFFERS; ii++)
  {
      // use the address of the data section so that the header is only accessed
      // as needed
      pMsgBuffer = & (BufferPool[ii].buffer[0]);
  
      // We only call this at initialization so it should never fail
      // params: queue handle, ptr to item to queue, ticks to wait if full
      if ( xQueueSend( QueueHandles[FREE_QINDEX], &pMsgBuffer, DONT_WAIT ) != pdTRUE )
      {
        PrintString("Unable to build Free Queue\r\n");
        SetBufferPoolFailureBit();
      }
  }
}
Exemplo n.º 3
0
void BPL_FreeMessageBuffer(unsigned char* pBuffer)
{
  // make sure the returned pointer is in range
  if (pBuffer < LOW_BUFFER_ADDRESS || pBuffer > HIGH_BUFFER_ADDRESS)
  {
    PrintString2("@ Free Buffer Corrupt", CR);
    SetBufferPoolFailureBit();
  }

  // params are: queue handle, ptr to item to queue, tick to wait if full
  // the queue can't be full unless there is a bug, so don't wait on full
  if(pdTRUE != xQueueSend(QueueHandles[FREE_QINDEX], &pBuffer, DONT_WAIT))
  {
    PrintString2("@ add buf to que", CR);
    SetBufferPoolFailureBit();
  }
}
Exemplo n.º 4
0
unsigned char* BPL_AllocMessageBuffer(void)
{
  unsigned char * pBuffer = NULL;

  // params are: queue handle, ptr to the msg buffer, ticks to wait
  if (pdTRUE != xQueueReceive(QueueHandles[FREE_QINDEX], &pBuffer, DONT_WAIT))
  {
    PrintString2("@ No MsgBuf", CR);
    SetBufferPoolFailureBit();

  }
  else if (pBuffer < LOW_BUFFER_ADDRESS || pBuffer > HIGH_BUFFER_ADDRESS)
  {
    PrintString2("@ Invalid MsgBuf", CR);
    SetBufferPoolFailureBit();
  }

  return pBuffer;
}
Exemplo n.º 5
0
unsigned char* BPL_AllocMessageBuffer(void)
{
  unsigned char * pBuffer = NULL;

  // params are: queue handle, ptr to the msg buffer, ticks to wait
  if( pdTRUE != xQueueReceive( QueueHandles[FREE_QINDEX], &pBuffer, DONT_WAIT ) )
  {
    PrintString("Unable to Allocate Buffer\r\n");
    SetBufferPoolFailureBit();
  }

  if (   pBuffer < LOW_BUFFER_ADDRESS 
      || pBuffer > HIGH_BUFFER_ADDRESS )
  {
    PrintString("Free Buffer Corruption\r\n");
    SetBufferPoolFailureBit();
}

  return pBuffer;

}
Exemplo n.º 6
0
/* This is too slow to use */
unsigned char* BPL_AllocMessageBufferFromISR(void)
{  
  unsigned char * pBuffer = NULL;

  signed portBASE_TYPE HigherPriorityTaskWoken;
  
  // params are: queue handle, ptr to the msg buffer, ticks to wait
  if( pdTRUE != xQueueReceiveFromISR(QueueHandles[FREE_QINDEX], 
                                     &pBuffer, 
                                     &HigherPriorityTaskWoken ))
  {
    PrintString2("@ Alloc Buf frm Isr", CR);
    SetBufferPoolFailureBit();
  }
  
  if ( HigherPriorityTaskWoken == pdTRUE )
  {
    portYIELD();
  }
  
  return pBuffer;
}