/* ** =================================================================== ** Method : COREUART_ASerialLdd2_OnError (component AsynchroSerial) ** ** Description : ** This event is called when a channel error (not the error ** returned by a given method) occurs. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ void ASerialLdd2_OnError(LDD_TUserData *UserDataPtr) { LDD_SERIAL_TError SerialErrorMask; /* Serial error mask variable */ (void)UserDataPtr; /* Parameter is not used, suppress unused argument warning */ (void)ASerialLdd2_GetError(ASerialLdd2_DeviceDataPtr, &SerialErrorMask); /* Get error state */ if (SerialErrorMask != 0U) { SerFlag |= (((SerialErrorMask & LDD_SERIAL_PARITY_ERROR) != 0U ) ? PARITY_ERR : 0U); SerFlag |= (((SerialErrorMask & LDD_SERIAL_NOISE_ERROR) != 0U ) ? NOISE_ERR : 0U); SerFlag |= (((SerialErrorMask & LDD_SERIAL_RX_OVERRUN) != 0U ) ? OVERRUN_ERR : 0U); SerFlag |= (((SerialErrorMask & LDD_SERIAL_FRAMING_ERROR) != 0U ) ? FRAMING_ERR : 0U); } }
/* ** =================================================================== ** 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 */ }