Exemple #1
0
/* Initialize debug output via UART for board */
void Board_Debug_Init(void)
{
#if defined(DEBUG_UART)
	Chip_UART0_Init(DEBUG_UART);
	Chip_UART0_SetBaud(DEBUG_UART, 115200);
	Chip_UART0_ConfigData(DEBUG_UART, (UART0_LCR_WLEN8 | UART0_LCR_SBS_1BIT));
	Chip_UART0_SetupFIFOS(DEBUG_UART, (UART0_FCR_FIFO_EN | UART0_FCR_TRG_LEV2));
	Chip_UART0_TXEnable(DEBUG_UART);
#endif
}
Exemple #2
0
void uart0_setup(uint32_t baudrate, uint32_t config) {
	/* Initialize UART0 */
	Chip_UART0_Init(LPC_USART0);
	Chip_UART0_SetBaud(LPC_USART0, baudrate);
	Chip_UART0_ConfigData(LPC_USART0, config);
	Chip_UART0_SetupFIFOS(LPC_USART0, (UART0_FCR_FIFO_EN | UART0_FCR_TRG_LEV2));
	Chip_UART0_TXEnable(LPC_USART0);

	RingBuffer_Init(&rxring, rxbuff, 1, UART0_READ_RB_SIZE);
	RingBuffer_Init(&txring, txbuff, 1, UART0_WRITE_RB_SIZE);

	Chip_UART0_IntEnable(LPC_USART0, (UART0_IER_RBRINT | UART0_IER_RLSINT));
	NVIC_EnableIRQ(USART0_IRQn);
}
Exemple #3
0
/**
 * [SER_Init  Initalize Uart Driver]
 */
void SER_Init (void) {
	
	uint8_t key;
	int bytes;
	
	Init_UART_PinMux();
	
  Chip_UART0_Init(LPC_USART0);
	Chip_UART0_SetBaud(LPC_USART0, 115200);
	Chip_UART0_ConfigData(LPC_USART0, (UART0_LCR_WLEN8 | UART0_LCR_SBS_1BIT));
	Chip_UART0_SetupFIFOS(LPC_USART0, (UART0_FCR_FIFO_EN | UART0_FCR_TRG_LEV2));
	Chip_UART0_TXEnable(LPC_USART0);
	
	
	/* Before using the ring buffers, initialize them using the ring
	   buffer init function */
	RingBuffer_Init(&rxring, rxbuff, 1, UART_RRB_SIZE);
	RingBuffer_Init(&txring, txbuff, 1, UART_SRB_SIZE);

	/* Enable receive data and line status interrupt */
	Chip_UART0_IntEnable(LPC_USART0, (UART0_IER_RBRINT | UART0_IER_RLSINT));

	/* Enable UART 0 interrupt */
	NVIC_EnableIRQ(USART0_IRQn);

	/* Send initial messages */
	Chip_UART0_SendRB(LPC_USART0, &txring, inst1, sizeof(inst1) - 1);
	Chip_UART0_SendRB(LPC_USART0, &txring, inst2, sizeof(inst2) - 1);

	/* Poll the receive ring buffer for the ESC (ASCII 27) key */
	key = 0;
//	while (key != ' ') {
//		bytes = Chip_UART0_ReadRB(LPC_USART0, &rxring, &key, 1);
//		if (bytes > 0) {
//			/* Wrap value back around */
//			if (Chip_UART0_SendRB(LPC_USART0, &txring, (const uint8_t *) &key, 1) != 1) {
//			}
//		}
//	}
}