void UART0_IRQHandler(void) { LPC_UART_API->uart_isr(uartHandle); } void setupUART(void) { uint32_t frg_mult; Chip_Clock_SetUARTClockDiv(1);/* divided by 1 */ Chip_UART_Init(LPC_USART0); /* 115.2KBPS, 8N1, ASYNC mode, no errors, clock filled in later */ UART_CONFIG_T cfg = { 0,/* U_PCLK frequency in Hz */ 115200,/* Baud Rate in Hz */ 1,/* 8N1 */ 0,/* Asynchronous Mode */ NO_ERR_EN/* Enable No Errors */ }; /* Setup the UART handle */ uartHandle = LPC_UART_API->uart_setup((uint32_t) LPC_USART0, (uint8_t *) &uartHandleMEM); cfg.sys_clk_in_hz = Chip_Clock_GetSystemClockRate(); /* Initialize the UART with the configuration parameters */ frg_mult = LPC_UART_API->uart_init(uartHandle, &cfg); if (frg_mult) { Chip_SYSCTL_SetUSARTFRGDivider(0xFF);/* value 0xFF should be always used */ Chip_SYSCTL_SetUSARTFRGMultiplier(frg_mult); } } |
/* Enable the IRQ for the UART */ NVIC_EnableIRQ(UART0_IRQn); _param.buffer = (uint8_t *) receive_buffer; _param.size = length; _param.transfer_mode = RX_MODE_LF_RECVD; _param.driver_mode = DRIVER_MODE_INTERRUPT; /* Setup the receive callback, this will get called when the transfer is complete */ _param.callback_func_pt = callback; /* Receive the data */ LPC_UART_API->uart_get_line(uartHandle, &_param); |
UART_PARAM_T param; /* Enable the IRQ for the UART */ NVIC_DisableIRQ(UART0_IRQn); param.buffer = (uint8_t *) receive_buffer; param.size = length; param.transfer_mode = RX_MODE_BUF_FULL; param.driver_mode = DRIVER_MODE_POLLING; /* Receive the data */ LPC_UART_API->uart_get_line(uartHandle, ¶m); |