示例#1
0
unsigned char AIR_UART_StrnPrint(unsigned char* pBuffer, unsigned int count)
{
	unsigned char i;
	char temp;
	
	for(i = 0; i < count; i++)
	{
		if((pBuffer[i] == '\0') || CircularBuffer_Write(&uartTXCircularBuffer, pBuffer[i]))
		{
			if(!CircularBuffer_Read(&uartTXCircularBuffer, &temp))
			{
				puart_write(temp);
				P_UART_INT_ENABLE |= P_UART_ISR_TX_FAE_MASK;
			}
			return i;
		}
	}
	
	if(!CircularBuffer_Read(&uartTXCircularBuffer, &temp))
	{
		puart_write(temp);
		P_UART_INT_ENABLE |= P_UART_ISR_TX_FAE_MASK;
	}
	return i;
}
示例#2
0
unsigned char AIR_UART_Print(unsigned char *pBuffer)
{
	unsigned char i;
	char temp;
	
	for(i = 0; i < AIR_UART_RX_CIRCULAR_BUFFER_SIZE; i++)
	{
		if((pBuffer[i] == '\0') || CircularBuffer_Write(&uartTXCircularBuffer, pBuffer[i]))
		{
			if(!CircularBuffer_Read(&uartTXCircularBuffer, &temp))
			{
				puart_write(temp);
				P_UART_INT_ENABLE |= P_UART_ISR_TX_FAE_MASK;
			}
			return i;
		}
	}
	
	if(!CircularBuffer_Read(&uartTXCircularBuffer, &temp))
	{
		puart_write(temp);
		P_UART_INT_ENABLE |= P_UART_ISR_TX_FAE_MASK;
	}
	return i;
}
void USART1_IRQHandler(void)
{
	uint32_t data;
	static BaseType_t xHigherPriorityTaskWoken;

	xHigherPriorityTaskWoken = pdFALSE;

	if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)
	{
		USART_ClearITPendingBit(USART1, USART_IT_RXNE);

		data = USART_ReceiveData(USART1);

		CircularBuffer_Write(ptxcbuf, &data, 1);
		
		USART_ITConfig(USART1, USART_IT_IDLE, ENABLE);

	}
	else if(USART_GetITStatus(USART1, USART_IT_IDLE) != RESET)
	{
		USART_ClearITPendingBit(USART1, USART_IT_IDLE);
		USART_ITConfig(USART1, USART_IT_IDLE, DISABLE);
			
		data = (CircularBuffer_Length(ptxcbuf) -  
				(lastHead- CircularBuffer_HeadPosition(ptxcbuf)))%CircularBuffer_Length(ptxcbuf);

		lastHead = CircularBuffer_HeadPosition(ptxcbuf);

		xQueueSendFromISR(frameLengthQueue, &data, &xHigherPriorityTaskWoken);

	}

	portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
示例#4
0
static void puart_rx_callback(void* unused)
{
	// There can be at most 16 bytes in the HW FIFO.
	char  readbyte;
	
	// empty the FIFO
	while(puart_rxFifoNotEmpty() && puart_read(&readbyte))
	{
		//We recieved a byte place it into the circle buffer.
		CircularBuffer_Write(&uartRXCircularBuffer, readbyte);
		
		if(uartRXCallback != NULL)
		{
			uartRXCallback(readbyte);
		}
	}
	
	P_UART_INT_CLEAR(P_UART_ISR_RX_AFF_MASK);
	// enable UART interrupt in the Main Interrupt Controller and RX Almost Full in the UART Interrupt Controller
	P_UART_INT_ENABLE |= P_UART_ISR_RX_AFF_MASK;
}