XilinxProcessorIPLib/drivers/uartns550/src/xuartns550_format.c
void XUartNs550_GetDataFormat(XUartNs550 *InstancePtr,
				XUartNs550Format *FormatPtr)
{
	u32 LcrRegister;

	Xil_AssertVoid(InstancePtr != NULL);
	Xil_AssertVoid(FormatPtr != NULL);

	/*
	 * Assert validates the input arguments
	 */
	Xil_AssertVoid(InstancePtr != NULL);
	Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);

	/*
	 * Get the baud rate from the instance, this is not retrieved from the
	 * hardware because it is only kept as a divisor such that it is more
	 * difficult to get back to the divisor
	 */
	FormatPtr->BaudRate = InstancePtr->BaudRate;

	/*
	 * Read the line control register which contains the parity, length and
	 * stop bits so they can be updated without affecting any other bits
	 */
	LcrRegister = XUartNs550_GetLineControlReg(InstancePtr->BaseAddress);

	/*
	 * Set the length of data (8,7,6,5) by first clearing out the bits
	 * that control it in the register, then set the length in the register
	 */
	FormatPtr->DataBits = LcrRegister & XUN_LCR_LENGTH_MASK;

	/*
	 * Set the number of stop bits by first clearing out the bits in that
	 * control it in the register, then set the bits in the register, the
	 * default is one stop bit after clearing the register bits
	 */
	if (LcrRegister & XUN_LCR_2_STOP_BITS) {
		FormatPtr->StopBits = XUN_FORMAT_2_STOP_BIT;
	} else {
		FormatPtr->StopBits = XUN_FORMAT_1_STOP_BIT;
	}

	/*
	 * Determine what parity is set from the register and setup the format
	 * to correspond
	 */
	if ((LcrRegister & XUN_LCR_ENABLE_PARITY) == 0) {
		FormatPtr->Parity = XUN_FORMAT_NO_PARITY;
	} else {

		/*
		 * Parity is enables, so determine if it's even or odd and set the
		 * format to correspond
		 */
		if (LcrRegister & XUN_LCR_EVEN_PARITY) {
			FormatPtr->Parity = XUN_FORMAT_EVEN_PARITY;
		} else {
			FormatPtr->Parity = XUN_FORMAT_ODD_PARITY;
		}
	}
}
/****************************************************************************/
/**
*
* Gets the data format for the specified UART. The data format includes the
* baud rate, number of data bits, number of stop bits, and parity.
*
* @param	InstancePtr is a pointer to the XUartNs550 instance.
* @param	FormatPtr is a pointer to a format structure that will contain
*		the data format after this call completes.
*
* @return	None.
*
* @note		None.
*
* @internal
*
* This function gets the state of the hardware rather than returning a state
* that has been stored to ensure that the hardware is correct.
*
*****************************************************************************/
Gets the data format for the specified UART. The data format includes the
baud rate, number of data bits, number of stop bits, and parity.
Gets the data format for the specified UART . The data format includes the baud rate number of data bits number of stop bits and parity .
void XUartNs550_GetDataFormat(XUartNs550 *InstancePtr,
				XUartNs550Format *FormatPtr)
{
	u32 LcrRegister;
	Xil_AssertVoid(InstancePtr != NULL);
	Xil_AssertVoid(FormatPtr != NULL);
	Xil_AssertVoid(InstancePtr != NULL);
	Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
	FormatPtr->BaudRate = InstancePtr->BaudRate;
	LcrRegister = XUartNs550_GetLineControlReg(InstancePtr->BaseAddress);
	FormatPtr->DataBits = LcrRegister & XUN_LCR_LENGTH_MASK;
	if (LcrRegister & XUN_LCR_2_STOP_BITS) {
		FormatPtr->StopBits = XUN_FORMAT_2_STOP_BIT;
	} else {
		FormatPtr->StopBits = XUN_FORMAT_1_STOP_BIT;
	}
	if ((LcrRegister & XUN_LCR_ENABLE_PARITY) == 0) {
		FormatPtr->Parity = XUN_FORMAT_NO_PARITY;
	} else {
		if (LcrRegister & XUN_LCR_EVEN_PARITY) {
			FormatPtr->Parity = XUN_FORMAT_EVEN_PARITY;
		} else {
			FormatPtr->Parity = XUN_FORMAT_ODD_PARITY;
		}
	}
}
void XUartNs550_GetDataFormat ( XUartNs550 * InstancePtr , XUartNs550Format * FormatPtr ) { u32 LcrRegister ; Xil_AssertVoid ( InstancePtr != NULL ) ; Xil_AssertVoid ( FormatPtr != NULL ) ; Xil_AssertVoid ( InstancePtr != NULL ) ; Xil_AssertVoid ( InstancePtr -> IsReady == XIL_COMPONENT_IS_READY ) ; FormatPtr -> BaudRate = InstancePtr -> BaudRate ; LcrRegister = XUartNs550_GetLineControlReg ( InstancePtr -> BaseAddress ) ; FormatPtr -> DataBits = LcrRegister & XUN_LCR_LENGTH_MASK ; if ( LcrRegister & XUN_LCR_2_STOP_BITS ) { FormatPtr -> StopBits = XUN_FORMAT_2_STOP_BIT ; } else { FormatPtr -> StopBits = XUN_FORMAT_1_STOP_BIT ; } if ( ( LcrRegister & XUN_LCR_ENABLE_PARITY ) == 0 ) { FormatPtr -> Parity = XUN_FORMAT_NO_PARITY ; } else { if ( LcrRegister & XUN_LCR_EVEN_PARITY ) { FormatPtr -> Parity = XUN_FORMAT_EVEN_PARITY ; } else { FormatPtr -> Parity = XUN_FORMAT_ODD_PARITY ; } } }
Gets the data format for the specified UART.
Gets the data format for the specified UART .
/*
	 * Assert validates the input arguments
	 */ /*
	 * Get the baud rate from the instance, this is not retrieved from the
	 * hardware because it is only kept as a divisor such that it is more
	 * difficult to get back to the divisor
	 */ /*
	 * Read the line control register which contains the parity, length and
	 * stop bits so they can be updated without affecting any other bits
	 */ /*
	 * Set the length of data (8,7,6,5) by first clearing out the bits
	 * that control it in the register, then set the length in the register
	 */ /*
	 * Set the number of stop bits by first clearing out the bits in that
	 * control it in the register, then set the bits in the register, the
	 * default is one stop bit after clearing the register bits
	 */ /*
	 * Determine what parity is set from the register and setup the format
	 * to correspond
	 */ /*
		 * Parity is enables, so determine if it's even or odd and set the
		 * format to correspond
		 */