void SerialInit(uint32_t baudrate){
uint32_t DL;
LPC_IOCON -> PIO1_7= (1 << 1);
LPC_SYSCON -> SYSAHBCLKCTRL|= (1 << 12);
LPC_SYSCON -> UARTCLKDIV= 0x01;//
DL = (SystemCoreClock * LPC_SYSCON -> SYSAHBCLKDIV)/(16 * baudrate * LPC_SYSCON -> UARTCLKDIV);
LPC_UART->LCR = 0b10000011;  //  8-bit character length, DLAB enable ( DLAB = 1)
LPC_UART->DLM = DL / 256;    //  Determines the baud rate of the UART (MSB Register)     (Access DLAB = 1)
LPC_UART->DLL = DL % 256;    //  Determines the baud rate of the UART (LSB Register)     (Access DLAB = 1)
LPC_UART->LCR = 0b00000011;  //  8-bit character length , DLAB disable ( DLAB = 0)
LPC_UART->FCR = 0b00000111;
}  |