XilinxProcessorIPLib/drivers/uartps/src/xuartps.c
s32 XUartPs_CfgInitialize(XUartPs *InstancePtr,
				   XUartPs_Config * Config, u32 EffectiveAddr)
{
	s32 Status;
	u32 ModeRegister;
	u32 BaudRate;

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

	/* Setup the driver instance using passed in parameters */
	InstancePtr->Config.BaseAddress = EffectiveAddr;
	InstancePtr->Config.InputClockHz = Config->InputClockHz;
#if defined  (XCLOCKING)
	InstancePtr->Config.RefClk = Config->RefClk;
#endif
	InstancePtr->Config.ModemPinsConnected = Config->ModemPinsConnected;

	/* Initialize other instance data to default values */
	InstancePtr->Handler = (XUartPs_Handler)XUartPs_StubHandler;

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

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

	/* Initialize the platform data */
	InstancePtr->Platform = XGetPlatform_Info();

	InstancePtr->is_rxbs_error = 0U;

	/* Flag that the driver instance is ready to use */
	InstancePtr->IsReady = XIL_COMPONENT_IS_READY;

	/*
	 * Set the default baud rate here, can be changed prior to
	 * starting the device
	 */
	BaudRate = (u32)XUARTPS_DFT_BAUDRATE;
	Status = XUartPs_SetBaudRate(InstancePtr, BaudRate);
	if (Status != (s32)XST_SUCCESS) {
		InstancePtr->IsReady = 0U;
	} else {

		/*
		 * Set up the default data format: 8 bit data, 1 stop bit, no
		 * parity
		 */
		ModeRegister = XUartPs_ReadReg(InstancePtr->Config.BaseAddress,
					  XUARTPS_MR_OFFSET);

		/* Mask off what's already there */
		ModeRegister &= (~((u32)XUARTPS_MR_CHARLEN_MASK |
						 (u32)XUARTPS_MR_STOPMODE_MASK |
						 (u32)XUARTPS_MR_PARITY_MASK));

		/* Set the register value to the desired data format */
		ModeRegister |=	((u32)XUARTPS_MR_CHARLEN_8_BIT |
						 (u32)XUARTPS_MR_STOPMODE_1_BIT |
						 (u32)XUARTPS_MR_PARITY_NONE);

		/* Write the mode register out */
		XUartPs_WriteReg(InstancePtr->Config.BaseAddress, XUARTPS_MR_OFFSET,
				   ModeRegister);

		/* Set the RX FIFO trigger at 8 data bytes. */
		XUartPs_WriteReg(InstancePtr->Config.BaseAddress,
				   XUARTPS_RXWM_OFFSET, 0x08U);

		/* Set the RX timeout to 1, which will be 4 character time */
		XUartPs_WriteReg(InstancePtr->Config.BaseAddress,
				   XUARTPS_RXTOUT_OFFSET, 0x01U);

		/* Disable all interrupts, polled mode is the default */
		XUartPs_WriteReg(InstancePtr->Config.BaseAddress, XUARTPS_IDR_OFFSET,
				   XUARTPS_IXR_MASK);

		Status = XST_SUCCESS;
	}
	return Status;
}
/****************************************************************************/
/**
*
* Initializes a specific XUartPs 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. The
* 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 XUartPs instance.
* @param	Config is a reference to a structure containing information
*		about a specific XUartPs driver.
* @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, pass in the physical
*		address instead.
*
* @return
*
*		- XST_SUCCESS if initialization was successful
*		- XST_UART_BAUD_ERROR if the baud rate is not possible because
*		  the inputclock frequency is not divisible with an acceptable
*		  amount of error
*
* @note
*
* The default configuration for the UART after initialization is:
*
* - 19,200 bps or XPAR_DFT_BAUDRATE if defined
* - 8 data bits
* - 1 stop bit
* - no parity
* - FIFO's are enabled with a receive threshold of 8 bytes
* - The RX timeout is enabled with a timeout of 1 (4 char times)
*
*   All interrupts are disabled.
*
*****************************************************************************/
Initializes a specific XUartPs 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. The
receive FIFO threshold is set for 8 bytes. The default operating mode of the
driver is polled mode.
Initializes a specific XUartPs 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 . The receive FIFO threshold is set for 8 bytes . The default operating mode of the driver is polled mode .
s32 XUartPs_CfgInitialize(XUartPs *InstancePtr,
				   XUartPs_Config * Config, u32 EffectiveAddr)
{
	s32 Status;
	u32 ModeRegister;
	u32 BaudRate;
	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(Config != NULL);
	InstancePtr->Config.BaseAddress = EffectiveAddr;
	InstancePtr->Config.InputClockHz = Config->InputClockHz;
#if defined  (XCLOCKING)
	InstancePtr->Config.RefClk = Config->RefClk;
#endif
	InstancePtr->Config.ModemPinsConnected = Config->ModemPinsConnected;
	InstancePtr->Handler = (XUartPs_Handler)XUartPs_StubHandler;
	InstancePtr->SendBuffer.NextBytePtr = NULL;
	InstancePtr->SendBuffer.RemainingBytes = 0U;
	InstancePtr->SendBuffer.RequestedBytes = 0U;
	InstancePtr->ReceiveBuffer.NextBytePtr = NULL;
	InstancePtr->ReceiveBuffer.RemainingBytes = 0U;
	InstancePtr->ReceiveBuffer.RequestedBytes = 0U;
	InstancePtr->Platform = XGetPlatform_Info();
	InstancePtr->is_rxbs_error = 0U;
	InstancePtr->IsReady = XIL_COMPONENT_IS_READY;
	BaudRate = (u32)XUARTPS_DFT_BAUDRATE;
	Status = XUartPs_SetBaudRate(InstancePtr, BaudRate);
	if (Status != (s32)XST_SUCCESS) {
		InstancePtr->IsReady = 0U;
	} else {
		ModeRegister = XUartPs_ReadReg(InstancePtr->Config.BaseAddress,
					  XUARTPS_MR_OFFSET);
		ModeRegister &= (~((u32)XUARTPS_MR_CHARLEN_MASK |
						 (u32)XUARTPS_MR_STOPMODE_MASK |
						 (u32)XUARTPS_MR_PARITY_MASK));
		ModeRegister |=	((u32)XUARTPS_MR_CHARLEN_8_BIT |
						 (u32)XUARTPS_MR_STOPMODE_1_BIT |
						 (u32)XUARTPS_MR_PARITY_NONE);
		XUartPs_WriteReg(InstancePtr->Config.BaseAddress, XUARTPS_MR_OFFSET,
				   ModeRegister);
		XUartPs_WriteReg(InstancePtr->Config.BaseAddress,
				   XUARTPS_RXWM_OFFSET, 0x08U);
		XUartPs_WriteReg(InstancePtr->Config.BaseAddress,
				   XUARTPS_RXTOUT_OFFSET, 0x01U);
		XUartPs_WriteReg(InstancePtr->Config.BaseAddress, XUARTPS_IDR_OFFSET,
				   XUARTPS_IXR_MASK);
		Status = XST_SUCCESS;
	}
	return Status;
}
s32 XUartPs_CfgInitialize ( XUartPs * InstancePtr , XUartPs_Config * Config , u32 EffectiveAddr ) { s32 Status ; u32 ModeRegister ; u32 BaudRate ; Xil_AssertNonvoid ( InstancePtr != NULL ) ; Xil_AssertNonvoid ( Config != NULL ) ; InstancePtr -> Config . BaseAddress = EffectiveAddr ; InstancePtr -> Config . InputClockHz = Config -> InputClockHz ; #if defined ( XCLOCKING ) InstancePtr -> Config . RefClk = Config -> RefClk ; #endif InstancePtr -> Config . ModemPinsConnected = Config -> ModemPinsConnected ; InstancePtr -> Handler = ( XUartPs_Handler ) XUartPs_StubHandler ; InstancePtr -> SendBuffer . NextBytePtr = NULL ; InstancePtr -> SendBuffer . RemainingBytes = 0U ; InstancePtr -> SendBuffer . RequestedBytes = 0U ; InstancePtr -> ReceiveBuffer . NextBytePtr = NULL ; InstancePtr -> ReceiveBuffer . RemainingBytes = 0U ; InstancePtr -> ReceiveBuffer . RequestedBytes = 0U ; InstancePtr -> Platform = XGetPlatform_Info ( ) ; InstancePtr -> is_rxbs_error = 0U ; InstancePtr -> IsReady = XIL_COMPONENT_IS_READY ; BaudRate = ( u32 ) XUARTPS_DFT_BAUDRATE ; Status = XUartPs_SetBaudRate ( InstancePtr , BaudRate ) ; if ( Status != ( s32 ) XST_SUCCESS ) { InstancePtr -> IsReady = 0U ; } else { ModeRegister = XUartPs_ReadReg ( InstancePtr -> Config . BaseAddress , XUARTPS_MR_OFFSET ) ; ModeRegister &= ( ~ ( ( u32 ) XUARTPS_MR_CHARLEN_MASK | ( u32 ) XUARTPS_MR_STOPMODE_MASK | ( u32 ) XUARTPS_MR_PARITY_MASK ) ) ; ModeRegister |= ( ( u32 ) XUARTPS_MR_CHARLEN_8_BIT | ( u32 ) XUARTPS_MR_STOPMODE_1_BIT | ( u32 ) XUARTPS_MR_PARITY_NONE ) ; XUartPs_WriteReg ( InstancePtr -> Config . BaseAddress , XUARTPS_MR_OFFSET , ModeRegister ) ; XUartPs_WriteReg ( InstancePtr -> Config . BaseAddress , XUARTPS_RXWM_OFFSET , 0x08U ) ; XUartPs_WriteReg ( InstancePtr -> Config . BaseAddress , XUARTPS_RXTOUT_OFFSET , 0x01U ) ; XUartPs_WriteReg ( InstancePtr -> Config . BaseAddress , XUARTPS_IDR_OFFSET , XUARTPS_IXR_MASK ) ; Status = XST_SUCCESS ; } return Status ; }
Initializes a specific XUartPs instance such that it is ready to be used.
Initializes a specific XUartPs instance such that it is ready to be used .
/* Assert validates the input arguments */ /* Setup the driver instance using passed in parameters */ /* Initialize other instance data to default values */ /* Initialize the platform data */ /* Flag that the driver instance is ready to use */ /*
	 * Set the default baud rate here, can be changed prior to
	 * starting the device
	 */ /*
		 * Set up the default data format: 8 bit data, 1 stop bit, no
		 * parity
		 */ /* Mask off what's already there */ /* Set the register value to the desired data format */ /* Write the mode register out */ /* Set the RX FIFO trigger at 8 data bytes. */ /* Set the RX timeout to 1, which will be 4 character time */ /* Disable all interrupts, polled mode is the default */