/**
 * This task will send any response data out of the UART.
 *
 * This should be called in the UART_OnTxChar event. Internally, the method checks to make sure the buffer
 * is empty and that the buffer is ready to send, so this method can also be called in the main application
 * loop.
 *
 * This method will automagically wiggle the TXEN line when necessary.
 */
void Command_ResponseTask()
{
	if(ResponseReadyToSend == FALSE)
		return;

//	if(UART_PDD_GetTxCompleteStatus(UART1_BASE_PTR) != 0x40u) // we're waiting for a transmit to complete already
//		return;
	if(UART_GetCharsInTxBuf() > 0)
		return; // we're waiting for a transmit to complete already

	if(ResponseIndex == 0)
	{
		TXEN_SetVal();
		for(int i=0;i<10000;i++);
	}

	// We have to wait a bit before we send our first byte.

	UART_SendChar(ResponseBuffer[ResponseIndex++]);
	if(ResponseIndex == COMMAND_RESPONSE_BUFFER_SIZE) // we've sent everything
	{
//		while(!(UART_PDD_ReadStatus1Flags(UART1_BASE_PTR) && UART_S1_TC_MASK) )
		while(UART_PDD_GetTxCompleteStatus(UART1_BASE_PTR) == 0U)
//		while(UART_GetCharsInTxBuf() > 0 );
//		for(int i=0;i<10000;i++);
		ResponseIndex = 0;
		ResponseReadyToSend = FALSE;
		TXEN_ClrVal();
		LED_GREEN_SetVal();
	}
}
Beispiel #2
0
void uartPrintString(char * myString)
{
	uint16_t i = 0;
	for(i = 0; i<strlen(myString);i++)
	{
		while(UART_PDD_GetTxCompleteStatus(UART0_DEVICE)==0);
		UART_PDD_PutChar8(UART0_DEVICE,myString[i]);
	}
}