Ejemplo n.º 1
0
/**
 * @brief	Handle interrupt from UART
 * @return	Nothing
 */
void UART1_IRQHandler(void)
{
	uint8_t ch;
	uint32_t IntStatus = Chip_UART_GetIntStatus(LPC_USART1);

	if (IntStatus & RXRDY_INT) {
		if(receiveCompleted == false) {
			Chip_UART_ReceiveByte(LPC_USART1, &RxBuf1[RxBufCnt1++]);
			if (RxBufCnt1 == BUFFER_SIZE) {
				Chip_UART_IntEnable(LPC_USART1, RXRDY_INT, DISABLE);
				receiveCompleted = true;
				RxBufCnt1 = 0;
			}
		}
		else {
			Chip_UART_ReceiveByte(LPC_USART1, &ch);
		}
	}

	if (IntStatus & TXRDY_INT) {
		if (sendCompleted == false) {
			Chip_UART_SendByte(LPC_USART1, RxBuf1[TxBufCnt1++]);
			if (TxBufCnt1 == BUFFER_SIZE) {
				Chip_UART_IntEnable(LPC_USART1, TXRDY_INT, DISABLE);
				sendCompleted = true;
				TxBufCnt1 = 0;
			}
		}
		else {
			return;
		}

	}
}
Ejemplo n.º 2
0
/* Gets a character from the UART, returns EOF if no character is ready */
int Board_UARTGetChar(void)
{
#if defined(DEBUG_ENABLE)
	uint8_t data;

	if (Chip_UART_ReceiveByte(DEBUG_UART, &data) == SUCCESS) {
		return (int) data;
	}
#endif
	return EOF;
}
Ejemplo n.º 3
0
void platform_uart_irq( platform_uart_driver_t* driver )
{
    platform_uart_port_t* uart = (platform_uart_port_t*) driver->interface->uart_base;
    uint8_t data=0;

    while (Chip_UART_GetLineStatus(uart) & UART_LSR_RDR) {
        Chip_UART_ReceiveByte(uart,&data);
        ring_buffer_write( driver->rx_buffer,&data, 1 );
    }

    // Notify thread if sufficient data are available
    if ( ( driver->rx_size > 0 ) && ( ring_buffer_used_space( driver->rx_buffer ) >= driver->rx_size ) )
    {
        host_rtos_set_semaphore( &driver->rx_complete, WICED_TRUE );
        driver->rx_size = 0;
    }
}
Ejemplo n.º 4
0
/**
 * @brief	Application main function
 * @return	Does not return
 * @note	This function will not return
 */
int main(void)
{
	uint32_t i;
	uint8_t repeat_num = UART_TEST_REPEAT_NUMBER;
	volatile int j = 1;
	uint8_t ch = 0;
	uint32_t IntStatus;

	/* Generic Initialization */
	Board_Init();

	Board_LED_Set(0, false);

	/* Disable UART1 IRQ */
	NVIC_DisableIRQ(UART1_IRQn);

	/* Initialize the UARTs */
	App_UART_Init(LPC_USART0);
	App_UART_Init(LPC_USART1);

	/* Custom Initialization */
	Chip_UART_IntEnable(LPC_USART1, RXRDY_INT, DISABLE);
	Chip_UART_IntEnable(LPC_USART1, TXRDY_INT, DISABLE);
	NVIC_EnableIRQ(UART1_IRQn);

	/* Data transfer loop */
	while (repeat_num--) {

		bufferInit(repeat_num);

		/* Sending from UART0 (polling mode) to UART1 (interrupt mode) */
		receiveCompleted = false;
		Chip_UART_IntEnable(LPC_USART1, RXRDY_INT, ENABLE);
		for (i = 0; i < BUFFER_SIZE; i++) {
			while (Chip_UART_SendByte(LPC_USART0, TxBuf0[i]) != SUCCESS) {}
		}
		while (!receiveCompleted) {}

        /* Clear Rx FIFO */
		Chip_UART_ReceiveByte(LPC_USART0, &ch);

		/* Sending from UART1 (interrupt mode) to UART0 (polling mode) */
		sendCompleted = false;
		Chip_UART_IntEnable(LPC_USART1, TXRDY_INT, ENABLE);
		for (i = 0; i < BUFFER_SIZE; i++) {
			while (Chip_UART_ReceiveByte(LPC_USART0, &RxBuf0[i]) != SUCCESS) {}
		}
		while (!sendCompleted) {}

		bufferCheck();
	}

	NVIC_DisableIRQ(UART1_IRQn);

	/* Test OK - Turn on Red LED */
	Board_LED_Set(0, true);

	/* Should not return */
	while (j) {}

	return 0;
}