Exemplo n.º 1
0
/*****************************************************************************
 *
 * Description:
 *    Blocking function that waits for a received character. 
 *
 * Return:
 *    The received character. 
 *
 ****************************************************************************/
tU8
uart1GetCh(void)
{
	tU8 rxChar;

  //wait for a character to be available
  while(uart1GetChar(&rxChar) == FALSE)
    ;
  return rxChar;
}
Exemplo n.º 2
0
/*****************************************************************************
 *
 * Description:
 *    Blocking (with semaphore) function that waits for a received character. 
 *
 * Return:
 *    The received character. 
 *
 ****************************************************************************/
tU8
uart1GetChSem(void)
{
	tU8 rxChar;
	tU8 error;

  //wait for a character to be available
  osSemTake(&receiveSem, 0, &error); //wait forever, no timeout

  //should never loop here, but just in case...
  while(uart1GetChar(&rxChar) == FALSE)
    ;
  return rxChar;
}
Exemplo n.º 3
0
tU32 readBackIfAvail() {
 tU32 rxChars = 0;

    tU8 rxChar = 0;
    
    //check if any character has been received
    while (TRUE == uart1GetChar(&rxChar))
    {
      rxChars++;
      if (rxChar == '\r')
        printf("\n%c", rxChar);
      else
        printf("%c", rxChar);
    }

	return rxChars;
}
Exemplo n.º 4
0
tU32 readBackTimed() {
  //get current time
   tU32 timeStamp = msClock;
 tU32 rxChars = 0;

  while((msClock - timeStamp) < 5000)
  {
    tU8 rxChar = 0;
    
    //check if any character has been received
    if (TRUE == uart1GetChar(&rxChar))
    {
      rxChars++;
      if (rxChar == '\r')
        printf("\n%c", rxChar);
      else
        printf("%c", rxChar);
    }
  }
  return rxChars;
}