Exemple #1
0
/*
** ===================================================================
**     Method      :  AS2_ASerialLdd2_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 ASerialLdd2_OnBlockReceived(LDD_TUserData *UserDataPtr)
{
  register byte Flags = 0U;            /* Temporary variable for flags */

  (void)UserDataPtr;                   /* Parameter is not used, suppress unused argument warning */
  if (AS2_InpLen < AS2_INP_BUF_SIZE) { /* Is number of bytes in the receive buffer lower than size of buffer? */
    AS2_InpLen++;                      /* Increase number of chars in the receive buffer */
    InpBuffer[InpIndexW++] = (AS2_TComData)BufferRead; /* Save received char to the receive buffer */
    if (InpIndexW >= AS2_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 (AS2_InpLen == AS2_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? */
    AS2_OnError();                     /* Invoke user event */
  } else {
    if ((Flags & ON_RX_CHAR) != 0U) {  /* Is OnRxChar flag set? */
      AS2_OnRxChar();                  /* Invoke user event */
    }
    if ((Flags & ON_FULL_RX) != 0U) {  /* Is OnTxChar flag set? */
      AS2_OnFullRxBuf();               /* Invoke user event */
    }
  }
  (void)ASerialLdd2_ReceiveBlock(ASerialLdd2_DeviceDataPtr, &BufferRead, 1U); /* Receive one data byte */
}
Exemple #2
0
/*
** ===================================================================
**     Method      :  HWEnDi (component AsynchroSerial)
**
**     Description :
**         Enables or disables the peripheral(s) associated with the bean.
**         The method is called automatically as a part of the Enable and 
**         Disable methods and several internal methods.
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
static void HWEnDi(void)
{
  if (EnUser) {                        /* Enable device? */
    (void)ASerialLdd2_Enable(ASerialLdd2_DeviceDataPtr); /* Enable device */
    (void)ASerialLdd2_ReceiveBlock(ASerialLdd2_DeviceDataPtr, &BufferRead, 1U); /* Receive one data byte */
    if ((COREUART_OutLen) != 0U) {     /* Is number of bytes in the transmit buffer greater then 0? */
      SerFlag |= RUNINT_FROM_TX;       /* Set flag "running int from TX"? */
      (void)ASerialLdd2_SendBlock(ASerialLdd2_DeviceDataPtr, (LDD_TData *)&OutBuffer[OutIndexR], 1U); /* Send one data byte */
    }
  } else {
    (void)ASerialLdd2_Disable(ASerialLdd2_DeviceDataPtr); /* Disable device */
  }
}
Exemple #3
0
/*
** ===================================================================
**     Method      :  COREUART_ASerialLdd2_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 ASerialLdd2_OnBlockReceived(LDD_TUserData *UserDataPtr)
{

  (void)UserDataPtr;                   /* Parameter is not used, suppress unused argument warning */
  if (COREUART_InpLen < COREUART_INP_BUF_SIZE) { /* Is number of bytes in the receive buffer lower than size of buffer? */
    COREUART_InpLen++;                 /* Increase number of chars in the receive buffer */
    InpBuffer[InpIndexW++] = (COREUART_TComData)BufferRead; /* Save received char to the receive buffer */
    if (InpIndexW >= COREUART_INP_BUF_SIZE) { /* Is the index out of the receive buffer? */
      InpIndexW = 0x00U;               /* Set index on the first item into the receive buffer */
    }
  } else {
    SerFlag |= FULL_RX;                /* Set flag "full RX buffer" */
  }
  (void)ASerialLdd2_ReceiveBlock(ASerialLdd2_DeviceDataPtr, &BufferRead, 1U); /* Receive one data byte */
}
Exemple #4
0
/*
** ===================================================================
**     Method      :  Inhr1_RecvChar (component AsynchroSerial)
**     Description :
**         If any data is received, this method returns one character,
**         otherwise it returns an error code (it does not wait for
**         data). This method is enabled only if the receiver property
**         is enabled.
**         [Note:] Because the preferred method to handle error and
**         break exception in the interrupt mode is to use events
**         <OnError> and <OnBreak> the return value ERR_RXEMPTY has
**         higher priority than other error codes. As a consequence the
**         information about an exception in interrupt mode is returned
**         only if there is a valid character ready to be read.
**     Parameters  :
**         NAME            - DESCRIPTION
**       * Chr             - Pointer to a received character
**     Returns     :
**         ---             - Error code, possible codes:
**                           ERR_OK - OK
**                           ERR_SPEED - This device does not work in
**                           the active speed mode
**                           ERR_RXEMPTY - No data in receiver
**                           ERR_BREAK - Break character is detected
**                           (only when the <Interrupt service> property
**                           is disabled and the <Break signal> property
**                           is enabled)
**                           ERR_COMMON - common error occurred (the
**                           <GetError> method can be used for error
**                           specification)
** ===================================================================
*/
byte Inhr1_RecvChar(Inhr1_TComData *Chr)
{
  byte Result = ERR_OK;                /* Return error code */
  LDD_SERIAL_TError SerialErrorMask;   /* Serial error mask variable */

  ASerialLdd2_Main(ASerialLdd2_DeviceDataPtr);
  if (ASerialLdd2_GetError(ASerialLdd2_DeviceDataPtr, &SerialErrorMask) == ERR_OK) { /* Get error state */
    if (SerialErrorMask != 0U) {
      Result = ERR_COMMON;             /* If yes then set common error value */
    } else {
      if (ASerialLdd2_GetReceivedDataNum(ASerialLdd2_DeviceDataPtr) == 0U) { /* Is not received char? */
        return ERR_RXEMPTY;            /* If yes then error is returned */
      }
    }
  }
  *Chr = BufferRead;                   /* Read the char */
  (void)ASerialLdd2_ReceiveBlock(ASerialLdd2_DeviceDataPtr, &BufferRead, 1U); /* Receive one data byte */
  ASerialLdd2_Main(ASerialLdd2_DeviceDataPtr);
  return Result;                       /* Return error code */
}
Exemple #5
0
/*
** ===================================================================
**     Method      :  HWEnDi (component AsynchroSerial)
**
**     Description :
**         Enables or disables the peripheral(s) associated with the bean.
**         The method is called automatically as a part of the Enable and 
**         Disable methods and several internal methods.
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
static void HWEnDi(void)
{
  (void)ASerialLdd2_ReceiveBlock(ASerialLdd2_DeviceDataPtr, &BufferRead, 1U); /* Receive one data byte */
}