コード例 #1
0
ファイル: AS1.c プロジェクト: thihaElec/my-git
/*
** ===================================================================
**     Method      :  AS1_ASerialLdd1_OnBlockReceived (component AsynchroSerial)
**
**     Description :
**         This event is called when the requested number of data is 
**         moved to the input buffer.
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
void ASerialLdd1_OnBlockReceived(LDD_TUserData *UserDataPtr)
{
  register byte Flags = 0U;            /* Temporary variable for flags */

  (void)UserDataPtr;                   /* Parameter is not used, suppress unused argument warning */
  if (AS1_InpLen < AS1_INP_BUF_SIZE) { /* Is number of bytes in the receive buffer lower than size of buffer? */
    AS1_InpLen++;                      /* Increase number of chars in the receive buffer */
    InpBuffer[InpIndexW++] = (AS1_TComData)BufferRead; /* Save received char to the receive buffer */
    if (InpIndexW >= AS1_INP_BUF_SIZE) { /* Is the index out of the receive buffer? */
      InpIndexW = 0x00U;               /* Set index on the first item into the receive buffer */
    }
    Flags |= ON_RX_CHAR;               /* If yes then set the OnRxChar flag */
    if (AS1_InpLen == AS1_INP_BUF_SIZE) { /* Is number of bytes in the receive buffer equal to the size of buffer? */
      Flags |= ON_FULL_RX;             /* Set flag "OnFullRxBuf" */
    }
  } else {
    SerFlag |= FULL_RX;                /* Set flag "full RX buffer" */
    Flags |= ON_ERROR;                 /* Set the OnError flag */
  }
  if ((Flags & ON_ERROR) != 0U) {      /* Is any error flag set? */
    AS1_OnError();                     /* Invoke user event */
  } else {
    if ((Flags & ON_RX_CHAR) != 0U) {  /* Is OnRxChar flag set? */
      AS1_OnRxChar();                  /* Invoke user event */
    }
    if ((Flags & ON_FULL_RX) != 0U) {  /* Is OnTxChar flag set? */
      AS1_OnFullRxBuf();               /* Invoke user event */
    }
  }
  (void)ASerialLdd1_ReceiveBlock(ASerialLdd1_DeviceDataPtr, &BufferRead, 1U); /* Receive one data byte */
}
コード例 #2
0
ファイル: AS1.c プロジェクト: jonyMarino/microsdhacel
void AS1_InterruptRx(void)
{
  AS1_TComData Data;                   /* Temporary variable for data */
  byte OnFlags = 0;                    /* Temporary variable for flags */

  Data = SCIDRL;                       /* Read data from the receiver */
  if(SerFlag & CHAR_IN_RX) {           /* Is a character already present in the receive buffer? */
    SerFlag |= OVERRUN_ERR;            /* If yes then set flag OVERRUN_ERR */
  } else {
    BufferRead = Data;
    SerFlag |= CHAR_IN_RX;             /* Set flag "char in RX buffer" */
    OnFlags |= ON_RX_CHAR;             /* Set flag "OnRxChar" */
  }
    if(OnFlags & ON_RX_CHAR) {         /* Is OnRxChar flag set? */
      AS1_OnRxChar();                  /* If yes then invoke user event */
    }
}