XilinxProcessorIPLib/drivers/ttcps/src/xttcps_options.c
s32 XTtcPs_SetOptions(XTtcPs *InstancePtr, u32 Options)
{
	u32 CountReg;
	u32 ClockReg;
	u32 Index;
	s32 Status = XST_SUCCESS;

	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);

	ClockReg = XTtcPs_ReadReg(InstancePtr->Config.BaseAddress,
				    XTTCPS_CLK_CNTRL_OFFSET);
	CountReg = XTtcPs_ReadReg(InstancePtr->Config.BaseAddress,
				    XTTCPS_CNT_CNTRL_OFFSET);

	/*
	 * Loop through the options table, turning the option on or off
	 * depending on whether the bit is set in the incoming options flag.
	 */
	for (Index = 0U; Index < XTTCPS_NUM_TMRCTR_OPTIONS; Index++) {
		if ((Options & TmrCtrOptionsTable[Index].Option) != (u32)0) {
			if(TmrCtrOptionsTable[Index].Register == XTTCPS_CLK_CNTRL_OFFSET) {
				ClockReg |= TmrCtrOptionsTable[Index].Mask;
			} else {
				CountReg |= TmrCtrOptionsTable[Index].Mask;
			}
		} else {
			if(TmrCtrOptionsTable[Index].Register == XTTCPS_CLK_CNTRL_OFFSET) {
				ClockReg &= ~TmrCtrOptionsTable[Index].Mask;
			} else {
				CountReg &= ~TmrCtrOptionsTable[Index].Mask;
			}
		}
	}

	/*
	 * Now write the registers. Leave it to the upper layers to restart the
	 * device.
	 */
	if (Status != (s32)XST_FAILURE ) {
		XTtcPs_WriteReg(InstancePtr->Config.BaseAddress,
				  XTTCPS_CLK_CNTRL_OFFSET, ClockReg);
		XTtcPs_WriteReg(InstancePtr->Config.BaseAddress,
				  XTTCPS_CNT_CNTRL_OFFSET, CountReg);
	}

	return Status;
}
/*****************************************************************************/
/**
*
* This function sets the options for the TTC device.
*
* @param	InstancePtr is a pointer to the XTtcPs instance.
* @param	Options contains the specified options to be set. This is a bit
*		mask where a 1 means to turn the option on, and a 0 means to
*		turn the option off. One or more bit values may be contained
*		in the mask. See the bit definitions named XTTCPS_*_OPTION in
*		the file xttcps.h.
*
* @return
*		- XST_SUCCESS if options are successfully set.
*		- XST_FAILURE if any of the options are unknown.
*
* @note		None
*
******************************************************************************/
This function sets the options for the TTC device.
This function sets the options for the TTC device .
s32 XTtcPs_SetOptions(XTtcPs *InstancePtr, u32 Options)
{
	u32 CountReg;
	u32 ClockReg;
	u32 Index;
	s32 Status = XST_SUCCESS;
	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
	ClockReg = XTtcPs_ReadReg(InstancePtr->Config.BaseAddress,
				    XTTCPS_CLK_CNTRL_OFFSET);
	CountReg = XTtcPs_ReadReg(InstancePtr->Config.BaseAddress,
				    XTTCPS_CNT_CNTRL_OFFSET);
	for (Index = 0U; Index < XTTCPS_NUM_TMRCTR_OPTIONS; Index++) {
		if ((Options & TmrCtrOptionsTable[Index].Option) != (u32)0) {
			if(TmrCtrOptionsTable[Index].Register == XTTCPS_CLK_CNTRL_OFFSET) {
				ClockReg |= TmrCtrOptionsTable[Index].Mask;
			} else {
				CountReg |= TmrCtrOptionsTable[Index].Mask;
			}
		} else {
			if(TmrCtrOptionsTable[Index].Register == XTTCPS_CLK_CNTRL_OFFSET) {
				ClockReg &= ~TmrCtrOptionsTable[Index].Mask;
			} else {
				CountReg &= ~TmrCtrOptionsTable[Index].Mask;
			}
		}
	}
	if (Status != (s32)XST_FAILURE ) {
		XTtcPs_WriteReg(InstancePtr->Config.BaseAddress,
				  XTTCPS_CLK_CNTRL_OFFSET, ClockReg);
		XTtcPs_WriteReg(InstancePtr->Config.BaseAddress,
				  XTTCPS_CNT_CNTRL_OFFSET, CountReg);
	}
	return Status;
}
s32 XTtcPs_SetOptions ( XTtcPs * InstancePtr , u32 Options ) { u32 CountReg ; u32 ClockReg ; u32 Index ; s32 Status = XST_SUCCESS ; Xil_AssertNonvoid ( InstancePtr != NULL ) ; Xil_AssertNonvoid ( InstancePtr -> IsReady == XIL_COMPONENT_IS_READY ) ; ClockReg = XTtcPs_ReadReg ( InstancePtr -> Config . BaseAddress , XTTCPS_CLK_CNTRL_OFFSET ) ; CountReg = XTtcPs_ReadReg ( InstancePtr -> Config . BaseAddress , XTTCPS_CNT_CNTRL_OFFSET ) ; for ( Index = 0U ; Index < XTTCPS_NUM_TMRCTR_OPTIONS ; Index ++ ) { if ( ( Options & TmrCtrOptionsTable [ Index ] . Option ) != ( u32 ) 0 ) { if ( TmrCtrOptionsTable [ Index ] . Register == XTTCPS_CLK_CNTRL_OFFSET ) { ClockReg |= TmrCtrOptionsTable [ Index ] . Mask ; } else { CountReg |= TmrCtrOptionsTable [ Index ] . Mask ; } } else { if ( TmrCtrOptionsTable [ Index ] . Register == XTTCPS_CLK_CNTRL_OFFSET ) { ClockReg &= ~ TmrCtrOptionsTable [ Index ] . Mask ; } else { CountReg &= ~ TmrCtrOptionsTable [ Index ] . Mask ; } } } if ( Status != ( s32 ) XST_FAILURE ) { XTtcPs_WriteReg ( InstancePtr -> Config . BaseAddress , XTTCPS_CLK_CNTRL_OFFSET , ClockReg ) ; XTtcPs_WriteReg ( InstancePtr -> Config . BaseAddress , XTTCPS_CNT_CNTRL_OFFSET , CountReg ) ; } return Status ; }
This function sets the options for the TTC device.
This function sets the options for the TTC device .
/*
	 * Loop through the options table, turning the option on or off
	 * depending on whether the bit is set in the incoming options flag.
	 */ /*
	 * Now write the registers. Leave it to the upper layers to restart the
	 * device.
	 */