/*******************************************************************************
* Function Name: UART_1_SpiUartDisableIntTx
****************************************************************************//**
*
*  Disables TX interrupt sources.
*
*  \return
*   Returns TX interrupt sources enabled before function call.
*
*******************************************************************************/
uint32 UART_1_SpiUartDisableIntTx(void)
{
    uint32 intSourceMask;

    intSourceMask = UART_1_GetTxInterruptMode();

    UART_1_SetTxInterruptMode(UART_1_NO_INTR_SOURCES);

    return (intSourceMask);
}
void main(){

    UART_1_Start();
	
	/* choose when we receive interrupts from tx and rx */
	UART_1_SetTxInterruptMode(UART_1_TX_STS_COMPLETE);
	UART_1_SetRxInterruptMode(UART_1_RX_STS_FIFO_NOTEMPTY);
	
	CyGlobalIntEnable;
    
	UART_1_ClearTxBuffer();
	UART_1_ClearRxBuffer();
	
	LCD_Char_1_Start();
	LCD_Char_1_Position(0,0);
	
	/* initialize our source data to index */
	int j;
	for(j = 0; j < DATA_SIZE; ++j){
		sourceData[j] = j;
	}
	
	/* enable our interrupt routines */
	isr_1_StartEx(tx_int);
	isr_2_StartEx(rx_int);	
		
	/* idle loop until we finish our transmission */	
 	while(!rx_done){}

 	int k;
	int errors = 0;
	/* data validation */
	for(k = 0; k < DATA_SIZE; ++k)
		if(sourceData[k] != receiveData[k]) ++errors;
	
	/* print errors to lcd */
	LCD_Char_1_PrintString("errors: ");
	LCD_Char_1_PrintNumber(errors);
	
	LCD_Char_1_Position(1,0);
	LCD_Char_1_PrintString("tx:");

	LCD_Char_1_PrintNumber(tx_cnt);
	LCD_Char_1_PrintString(" rx:");

	LCD_Char_1_PrintNumber(rx_cnt);

	for(;;){
	
    }
}
Beispiel #3
0
xComPortHandle xSerialPortInitMinimal( unsigned long ulWantedBaud, unsigned portBASE_TYPE uxQueueLength )
{
	/* Configure Rx. */
	xSerialRxQueue = xQueueCreate( uxQueueLength, sizeof( signed char ) );	
	isr_UART1_RX_BYTE_RECEIVED_ClearPending();
	isr_UART1_RX_BYTE_RECEIVED_StartEx(vUartRxISR);

	/* Configure Tx */
	xSerialTxQueue = xQueueCreate( uxQueueLength, sizeof( signed char ) );
	isr_UART1_TX_BYTE_COMPLETE_ClearPending() ;
	isr_UART1_TX_BYTE_COMPLETE_StartEx(vUartTxISR);

	/* Clear the interrupt modes for the Tx for the time being. */
	UART_1_SetTxInterruptMode( 0 );

	/* Both configured successfully. */
	return ( xComPortHandle )( xSerialTxQueue && xSerialRxQueue );
}
Beispiel #4
0
signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed char cOutChar, TickType_t xBlockTime )
{
portBASE_TYPE xReturn = pdFALSE;

	/* The ISR is processing characters is so just add to the end of the queue. */
	if( pdTRUE == xQueueSend( xSerialTxQueue, &cOutChar, xBlockTime ) )
	{	
		xReturn = pdTRUE;
	}
	else
	{
		/* The queue is probably full. */
		xReturn = pdFALSE;
	}

	/* Make sure that the interrupt will fire in the case where:
	    Currently sending so the Tx Complete will fire.
	    Not sending so the Empty will fire.	*/
	taskENTER_CRITICAL();
		UART_1_SetTxInterruptMode( UART_1_TX_STS_COMPLETE | UART_1_TX_STS_FIFO_EMPTY );
	taskEXIT_CRITICAL();
	
	return xReturn;
}