XilinxProcessorIPLib/drivers/dp14txss/examples/src/zcu_pt_dp14_hdcp/menus.c
char xil_getc(u32 timeout_ms){
	char c;
	u32 timeout = 0;

	extern XTmrCtr TmrCtr;

	// Reset and start timer
	if ( timeout_ms > 0 && timeout_ms != 0xff ){
	  XTmrCtr_Start(&TmrCtr, 0);
	}


	while((!XUartPs_IsReceiveData(STDIN_BASEADDRESS)) && (timeout == 0)){
		if ( timeout_ms == 0 ){ // no timeout - wait for ever
		   timeout = 0;
		} else if ( timeout_ms == 0xff ) { // no wait - special case
		   timeout = 1;
		} else if(timeout_ms > 0){
			if(XTmrCtr_GetValue(&TmrCtr, 0)
										> ( timeout_ms * (100000000 / 1000) )){
				timeout = 1;
			}
		}
	}
	if(timeout == 1){
		c = 0;
	} else {
		c = XUartPs_RecvByte_NonBlocking();
	}
	return c;
}
/*****************************************************************************/
/**
*
* This function to get uart input from user
*
* @param	timeout_ms
*
* @return
*		- received charactor
*
* @note		None.
*
******************************************************************************/
This function to get uart input from user
This function to get uart input from user
char xil_getc(u32 timeout_ms){
	char c;
	u32 timeout = 0;
	extern XTmrCtr TmrCtr;
	if ( timeout_ms > 0 && timeout_ms != 0xff ){
	  XTmrCtr_Start(&TmrCtr, 0);
	}
	while((!XUartPs_IsReceiveData(STDIN_BASEADDRESS)) && (timeout == 0)){
		if ( timeout_ms == 0 ){ 
		   timeout = 0;
		} else if ( timeout_ms == 0xff ) { 
		   timeout = 1;
		} else if(timeout_ms > 0){
			if(XTmrCtr_GetValue(&TmrCtr, 0)
										> ( timeout_ms * (100000000 / 1000) )){
				timeout = 1;
			}
		}
	}
	if(timeout == 1){
		c = 0;
	} else {
		c = XUartPs_RecvByte_NonBlocking();
	}
	return c;
}
char xil_getc ( u32 timeout_ms ) { char c ; u32 timeout = 0 ; extern XTmrCtr TmrCtr ; if ( timeout_ms > 0 && timeout_ms != 0xff ) { XTmrCtr_Start ( & TmrCtr , 0 ) ; } while ( ( ! XUartPs_IsReceiveData ( STDIN_BASEADDRESS ) ) && ( timeout == 0 ) ) { if ( timeout_ms == 0 ) { timeout = 0 ; } else if ( timeout_ms == 0xff ) { timeout = 1 ; } else if ( timeout_ms > 0 ) { if ( XTmrCtr_GetValue ( & TmrCtr , 0 ) > ( timeout_ms * ( 100000000 / 1000 ) ) ) { timeout = 1 ; } } } if ( timeout == 1 ) { c = 0 ; } else { c = XUartPs_RecvByte_NonBlocking ( ) ; } return c ; }
This function to get uart input from user
This function to get uart input from user
// Reset and start timer // no timeout - wait for ever // no wait - special case