Example #1
0
/* Notes      :(1) The first line of code is used to prevent a compiler warning because 'p_arg' is not
*                   used.  The compiler should not generate any code for this statement.
*
*
*********************************************************************************************************
*/
void APP_TaskTwo(void *p_arg)
{
  int taskChar;                   // Character received.

  (void)p_arg;  /* Note(1) */
  OS_ERR err = OS_ERR_NONE;

  while (1)
  { /* Task body, always written as an infinite loop  */

    /* Load character received on serial to character buffer */
    taskChar = UART1_ReadChar();

    /* If the character in the buffer is valid... */
    if ( (taskChar >= 32) && (taskChar < 128) )
    {
      /* Post the message to the mailbox */
      OSQPost((OS_Q        *) pSerialQueObj,
              (void        *) taskChar,
              (OS_MSG_SIZE  ) 1U,
              (OS_OPT       ) (OS_OPT_POST_FIFO | OS_OPT_POST_ALL),
              (OS_ERR      *) &err);

      if(OS_ERR_NONE != err)
      {
        /* Error has occured, handle can be done here */
      }
    }

    /* Delay task for 1 system tick (uC/OS-III suspends this task and executes
     * the next most important task) */
    OSTimeDly(1U, OS_OPT_TIME_DLY, &err);
  }
}
Example #2
0
/* Notes      :(1) The first line of code is used to prevent a compiler warning because 'p_arg' is not
*                   used.  The compiler should not generate any code for this statement.
*
*
*********************************************************************************************************
*/
void APP_TaskTwo(void *p_arg)
{
  int taskChar;                   // Character received.

  (void)p_arg;  /* Note(1) */

  while (1)
  { /* Task body, always written as an infinite loop  */

    /* Load character received on serial to character buffer */
    taskChar = UART1_ReadChar();

    /* If the character in the buffer is valid... */
    if ( (taskChar >= 32) && (taskChar < 128) )
    {
      /* Post the message to the mailbox */
      if (OS_ERR_NONE != OSQPost(pSerialQueObj, (void*)taskChar))
      {
        /* Error can be handled here */
      }
    }

    /* Delay task for 1 system tick (uC/OS-II suspends this task and executes
     * the next most important task) */
    OSTimeDly(1);
  }
}
/* Notes      :(1) The first line of code is used to prevent a compiler warning because 'p_arg' is not
*                   used.  The compiler should not generate any code for this statement.
*
*
*********************************************************************************************************
*/
void APP_TaskTwo(void *p_arg)
{
  static char taskMsg[CHAR_BUFFER_SIZE]; /* buffer for received characters to be passed to TaskThree */
  signed int  taskCharBuffer = -1; /* Character buffer for receiving */
  unsigned char bufIndex = 0;

  (void)p_arg;  /* Note(1) */

  while (1)
  { /* Task body, always written as an infinite loop  */

    /* Load character received on serial to character buffer */
    taskCharBuffer = UART1_ReadChar();

    /* If the character in the buffer is valid... */
    if ( (taskCharBuffer >= 32) && (taskCharBuffer < 128) )
    {
      /* ...cast and copy it to message buffer variable... */
      taskMsg[bufIndex] = (char)taskCharBuffer;

      /* ...and post the message to the mailbox */
      if(OS_ERR_NONE != OSMboxPost(pSerialMsgObj, &taskMsg[bufIndex]))
      {
        /* Error has occured, handle can be done here */
      }

      bufIndex++;
      if(bufIndex >= CHAR_BUFFER_SIZE)
        bufIndex = 0;
    }

    /* Delay task for 1 system tick (uC/OS-II suspends this task and executes
     * the next most important task) */
    OSTimeDly(1);
  }
}