/* ** =================================================================== ** Method : UART_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 (UART_InpLen < UART_INP_BUF_SIZE) { /* Is number of bytes in the receive buffer lower than size of buffer? */ UART_InpLen++; /* Increase number of chars in the receive buffer */ InpBuffer[InpIndexW++] = (UART_TComData)BufferRead; /* Save received char to the receive buffer */ if (InpIndexW >= UART_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 (UART_InpLen == UART_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? */ UART_OnError(); /* Invoke user event */ } else { if ((Flags & ON_RX_CHAR) != 0U) { /* Is OnRxChar flag set? */ UART_OnRxChar(); /* Invoke user event */ } if ((Flags & ON_FULL_RX) != 0U) { /* Is OnTxChar flag set? */ UART_OnFullRxBuf(); /* Invoke user event */ } } (void)ASerialLdd1_ReceiveBlock(ASerialLdd1_DeviceDataPtr, &BufferRead, 1U); /* Receive one data byte */ }
/* ** =================================================================== ** 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)ASerialLdd1_Enable(ASerialLdd1_DeviceDataPtr); /* Enable device */ (void)ASerialLdd1_ReceiveBlock(ASerialLdd1_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)ASerialLdd1_SendBlock(ASerialLdd1_DeviceDataPtr, (LDD_TData *)&OutBuffer[OutIndexR], 1U); /* Send one data byte */ } } else { SerFlag &= (byte)~(RUNINT_FROM_TX); /* Clear RUNINT_FROM_TX flag */ (void)ASerialLdd1_Disable(ASerialLdd1_DeviceDataPtr); /* Disable device */ } }
/* ** =================================================================== ** 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) { (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 */ } } else { SerFlag |= FULL_RX; /* Set flag "full RX buffer" */ } (void)ASerialLdd1_ReceiveBlock(ASerialLdd1_DeviceDataPtr, &BufferRead, 1U); /* Receive one data byte */ }
/* ** =================================================================== ** Method : ASerial_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 ((SerFlag & CHAR_IN_RX) != 0U) { /* Is the overrun error flag set? */ SerFlag |= OVERRUN_ERR; /* If yes then set the Error flag for RecvChar/Block method */ Flags |= ON_ERROR; /* If yes then set the OnError flag */ } SerFlag |= CHAR_IN_RX; /* Set flag "char in RX buffer" */ if ((Flags & ON_ERROR) != 0U) { /* Is any error flag set? */ ASerial_OnError(); /* Invoke user event */ } else { ASerial_OnRxChar(); /* Invoke user event */ } (void)ASerialLdd1_ReceiveBlock(ASerialLdd1_DeviceDataPtr, &BufferRead, 1U); /* Receive one data byte */ }
/* ** =================================================================== ** 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 */ ASerialLdd1_Main(ASerialLdd1_DeviceDataPtr); if (ASerialLdd1_GetError(ASerialLdd1_DeviceDataPtr, &SerialErrorMask) == ERR_OK) { /* Get error state */ if (SerialErrorMask != 0U) { Result = ERR_COMMON; /* If yes then set common error value */ } else { if (ASerialLdd1_GetReceivedDataNum(ASerialLdd1_DeviceDataPtr) == 0U) { /* Is not received char? */ return ERR_RXEMPTY; /* If yes then error is returned */ } } } *Chr = BufferRead; /* Read the char */ (void)ASerialLdd1_ReceiveBlock(ASerialLdd1_DeviceDataPtr, &BufferRead, 1U); /* Receive one data byte */ ASerialLdd1_Main(ASerialLdd1_DeviceDataPtr); return Result; /* Return error code */ }
/* ** =================================================================== ** 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)ASerialLdd1_ReceiveBlock(ASerialLdd1_DeviceDataPtr, &BufferRead, 1U); /* Receive one data byte */ }