lpc176x: Add an enable_peripheral_clock() helper function

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor
2018-11-21 20:33:44 -05:00
parent 9ba94ded9e
commit 4bbd631086
4 changed files with 23 additions and 5 deletions

View File

@@ -16,7 +16,7 @@ serial_init(void)
{
// Setup baud
LPC_UART0->LCR = (1<<7); // set DLAB bit
LPC_SC->PCLKSEL0 = (LPC_SC->PCLKSEL0 & ~(0x3<<6)) | (0x1<<6);
enable_peripheral_clock(PCLK_UART0);
uint32_t pclk = SystemCoreClock;
uint32_t div = pclk / (CONFIG_SERIAL_BAUD * 16);
LPC_UART0->DLL = div & 0xff;