XilinxProcessorIPLib/drivers/uartns550/src/xuartns550.c
int XUartNs550_CfgInitialize(XUartNs550 *InstancePtr,
					XUartNs550_Config *Config,
					UINTPTR EffectiveAddr)
{
	int Status;
	u32 BaudRate;

	/*
	 * Assert validates the input arguments
	 */
	Xil_AssertNonvoid(InstancePtr != NULL);

	/*
	 * Setup the data that is from the configuration information
	 */
	InstancePtr->BaseAddress = EffectiveAddr;
	InstancePtr->InputClockHz = Config->InputClockHz;

	/*
	 * Initialize the instance data to some default values and setup
	 * a default handler
	 */
	InstancePtr->Handler = XUartNs550_StubHandler;

	InstancePtr->SendBuffer.NextBytePtr = NULL;
	InstancePtr->SendBuffer.RemainingBytes = 0;
	InstancePtr->SendBuffer.RequestedBytes = 0;

	InstancePtr->ReceiveBuffer.NextBytePtr = NULL;
	InstancePtr->ReceiveBuffer.RemainingBytes = 0;
	InstancePtr->ReceiveBuffer.RequestedBytes = 0;

	/*
	 * Indicate the instance is now ready to use, initialized without error
	 */
	InstancePtr->IsReady = XIL_COMPONENT_IS_READY;

	/*
	 * Set the default Baud rate here, can be changed prior to
	 * starting the device
	 */
	BaudRate = Config->DefaultBaudRate;
	if (! BaudRate) {
		BaudRate = 19200;
	}

	Status = XUartNs550_SetBaudRate(InstancePtr, BaudRate);
	if (Status != XST_SUCCESS) {
		InstancePtr->IsReady = 0;
		return Status;
	}


	/*
	 * Set up the default format for the data, 8 bit data, 1 stop bit,
	 * no parity
	 */
	XUartNs550_SetLineControlReg(InstancePtr->BaseAddress,
						XUN_FORMAT_8_BITS);

	/*
	 * Enable the FIFOs assuming they are present and set the receive FIFO
	 * trigger level for 8 bytes assuming that this will work best with most
	 * baud rates, enabling the FIFOs also clears them, note that this must
	 * be done with 2 writes, 1st enabling the FIFOs then set the trigger
	 * level
	 */
	XUartNs550_WriteReg(InstancePtr->BaseAddress,
				XUN_FCR_OFFSET, XUN_FIFO_ENABLE);
	XUartNs550_WriteReg(InstancePtr->BaseAddress, XUN_FCR_OFFSET,
				XUN_FIFO_ENABLE | XUN_FIFO_RX_TRIG_MSB);
	/*
	 * Clear the statistics for this driver
	 */
	XUartNs550_ClearStats(InstancePtr);

	return XST_SUCCESS;
}
/****************************************************************************/
/**
*
* Initializes a specific XUartNs550 instance such that it is ready to be used.
* The data format of the device is setup for 8 data bits, 1 stop bit, and no
* parity by default. The baud rate is set to a default value specified by
* Config->DefaultBaudRate if set, otherwise it is set to 19.2K baud. If the
* device has FIFOs (16550), they are enabled and the a receive FIFO threshold
* is set for 8 bytes. The default operating mode of the driver is polled mode.
*
* @param 	InstancePtr is a pointer to the XUartNs550 instance.
* @param 	Config is a reference to a structure containing information
*		about a specific UART 16450/16550 device. XUartNs550_Init
*		initializes an InstancePtr object for a specific device
*		specified by the contents f Config. XUartNs550_Init can
*		initialize multiple instance objects with the use of multiple
*		calls giving different Config information on each call.
* @param 	EffectiveAddr is the device base address in the virtual memory
*		address	space. The caller is responsible for keeping the
*		address mapping from EffectiveAddr to the device physical base
*		address unchanged once this function is invoked. Unexpected
*		errors may occur if the address mapping changes after this
*		function is called. If address translation is not used,
*		use Config->BaseAddress for this parameters, passing the
*		physical address instead.
*
* @return
* 		- XST_SUCCESS if initialization was successful.
* 		- XST_UART_BAUD_ERROR if the baud rate is not possible because
*		the input clock frequency is not divisible with an acceptable
*		amount of error.
*
* @note		None.
*
*****************************************************************************/
Initializes a specific XUartNs550 instance such that it is ready to be used.
The data format of the device is setup for 8 data bits, 1 stop bit, and no
parity by default. The baud rate is set to a default value specified by
Config->DefaultBaudRate if set, otherwise it is set to 19.2K baud. If the
device has FIFOs (16550), they are enabled and the a receive FIFO threshold
is set for 8 bytes. The default operating mode of the driver is polled mode.
Initializes a specific XUartNs550 instance such that it is ready to be used . The data format of the device is setup for 8 data bits 1 stop bit and no parity by default . The baud rate is set to a default value specified by Config - > DefaultBaudRate if set otherwise it is set to 19 . 2K baud . If the device has FIFOs ( 16550 ) they are enabled and the a receive FIFO threshold is set for 8 bytes . The default operating mode of the driver is polled mode .
int XUartNs550_CfgInitialize(XUartNs550 *InstancePtr,
					XUartNs550_Config *Config,
					UINTPTR EffectiveAddr)
{
	int Status;
	u32 BaudRate;
	Xil_AssertNonvoid(InstancePtr != NULL);
	InstancePtr->BaseAddress = EffectiveAddr;
	InstancePtr->InputClockHz = Config->InputClockHz;
	InstancePtr->Handler = XUartNs550_StubHandler;
	InstancePtr->SendBuffer.NextBytePtr = NULL;
	InstancePtr->SendBuffer.RemainingBytes = 0;
	InstancePtr->SendBuffer.RequestedBytes = 0;
	InstancePtr->ReceiveBuffer.NextBytePtr = NULL;
	InstancePtr->ReceiveBuffer.RemainingBytes = 0;
	InstancePtr->ReceiveBuffer.RequestedBytes = 0;
	InstancePtr->IsReady = XIL_COMPONENT_IS_READY;
	BaudRate = Config->DefaultBaudRate;
	if (! BaudRate) {
		BaudRate = 19200;
	}
	Status = XUartNs550_SetBaudRate(InstancePtr, BaudRate);
	if (Status != XST_SUCCESS) {
		InstancePtr->IsReady = 0;
		return Status;
	}
	XUartNs550_SetLineControlReg(InstancePtr->BaseAddress,
						XUN_FORMAT_8_BITS);
	XUartNs550_WriteReg(InstancePtr->BaseAddress,
				XUN_FCR_OFFSET, XUN_FIFO_ENABLE);
	XUartNs550_WriteReg(InstancePtr->BaseAddress, XUN_FCR_OFFSET,
				XUN_FIFO_ENABLE | XUN_FIFO_RX_TRIG_MSB);
	XUartNs550_ClearStats(InstancePtr);
	return XST_SUCCESS;
}
int XUartNs550_CfgInitialize ( XUartNs550 * InstancePtr , XUartNs550_Config * Config , UINTPTR EffectiveAddr ) { int Status ; u32 BaudRate ; Xil_AssertNonvoid ( InstancePtr != NULL ) ; InstancePtr -> BaseAddress = EffectiveAddr ; InstancePtr -> InputClockHz = Config -> InputClockHz ; InstancePtr -> Handler = XUartNs550_StubHandler ; InstancePtr -> SendBuffer . NextBytePtr = NULL ; InstancePtr -> SendBuffer . RemainingBytes = 0 ; InstancePtr -> SendBuffer . RequestedBytes = 0 ; InstancePtr -> ReceiveBuffer . NextBytePtr = NULL ; InstancePtr -> ReceiveBuffer . RemainingBytes = 0 ; InstancePtr -> ReceiveBuffer . RequestedBytes = 0 ; InstancePtr -> IsReady = XIL_COMPONENT_IS_READY ; BaudRate = Config -> DefaultBaudRate ; if ( ! BaudRate ) { BaudRate = 19200 ; } Status = XUartNs550_SetBaudRate ( InstancePtr , BaudRate ) ; if ( Status != XST_SUCCESS ) { InstancePtr -> IsReady = 0 ; return Status ; } XUartNs550_SetLineControlReg ( InstancePtr -> BaseAddress , XUN_FORMAT_8_BITS ) ; XUartNs550_WriteReg ( InstancePtr -> BaseAddress , XUN_FCR_OFFSET , XUN_FIFO_ENABLE ) ; XUartNs550_WriteReg ( InstancePtr -> BaseAddress , XUN_FCR_OFFSET , XUN_FIFO_ENABLE | XUN_FIFO_RX_TRIG_MSB ) ; XUartNs550_ClearStats ( InstancePtr ) ; return XST_SUCCESS ; }
Initializes a specific XUartNs550 instance such that it is ready to be used.
Initializes a specific XUartNs550 instance such that it is ready to be used .
/*
	 * Assert validates the input arguments
	 */ /*
	 * Setup the data that is from the configuration information
	 */ /*
	 * Initialize the instance data to some default values and setup
	 * a default handler
	 */ /*
	 * Indicate the instance is now ready to use, initialized without error
	 */ /*
	 * Set the default Baud rate here, can be changed prior to
	 * starting the device
	 */ /*
	 * Set up the default format for the data, 8 bit data, 1 stop bit,
	 * no parity
	 */ /*
	 * Enable the FIFOs assuming they are present and set the receive FIFO
	 * trigger level for 8 bytes assuming that this will work best with most
	 * baud rates, enabling the FIFOs also clears them, note that this must
	 * be done with 2 writes, 1st enabling the FIFOs then set the trigger
	 * level
	 */ /*
	 * Clear the statistics for this driver
	 */