drivers/serial/uart_nxp_lpc1xxx.c
/* Determines and sets best dividers to get a target bit rate */
Determines and sets best dividers to get a target bit rate
Determines and sets best dividers to get a target bit rate
uint32_t Chip_UART_SetBaud(volatile _uart *pUART, uint32_t baudrate)
{
	uint32_t div, divh, divl, clkin;
	clkin = Soc_Clock_GetPeripheralClockRate(Chip_UART_GetClkIndex(pUART));
	div = clkin / (baudrate * 16);
	divh = div / 256;
	divl = div - (divh * 256);
	pUART->LCR |= UART_LCR_DLAB_EN;
	pUART->DLL = (uint32_t) divl;
	pUART->DLM = (uint32_t) divh;
	pUART->LCR &= ~UART_LCR_DLAB_EN;
	return clkin / div;
}
uint32_t Chip_UART_SetBaud ( volatile _uart * pUART , uint32_t baudrate ) { uint32_t div , divh , divl , clkin ; clkin = Soc_Clock_GetPeripheralClockRate ( Chip_UART_GetClkIndex ( pUART ) ) ; div = clkin / ( baudrate * 16 ) ; divh = div / 256 ; divl = div - ( divh * 256 ) ; pUART -> LCR |= UART_LCR_DLAB_EN ; pUART -> DLL = ( uint32_t ) divl ; pUART -> DLM = ( uint32_t ) divh ; pUART -> LCR &= ~ UART_LCR_DLAB_EN ; return clkin / div ; }
Determines and sets best dividers to get a target bit rate
Determines and sets best dividers to get a target bit rate
/* Determine UART clock in rate without FDR */ /* High and low halves of the divider */ /* Fractional FDR already setup for 1 in UART init */