Skip to content

Commit 5ea882a

Browse files
author
Adrian Negreanu
committed
lpc43xx_hic,uart: replace CGU code with direct register setup
1 parent 887c9fb commit 5ea882a

File tree

1 file changed

+9
-5
lines changed
  • source/hic_hal/nxp/lpc4322

1 file changed

+9
-5
lines changed

source/hic_hal/nxp/lpc4322/uart.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
#include "LPC43xx.h"
2323
#include "uart.h"
24-
#include "lpc43xx_cgu.h"
2524
#include "lpc43xx_scu.h"
2625
#include "util.h"
2726
#include "circ_buf.h"
@@ -31,8 +30,6 @@ static uint32_t baudrate;
3130
static uint32_t dll;
3231
static uint32_t tx_in_progress;
3332

34-
extern uint32_t SystemCoreClock;
35-
3633
#define RX_OVRF_MSG "<DAPLink:Overflow>\n"
3734
#define RX_OVRF_MSG_SIZE (sizeof(RX_OVRF_MSG) - 1)
3835
#define BUFFER_SIZE (512)
@@ -56,11 +53,18 @@ static int32_t reset(void);
5653

5754
int32_t uart_initialize(void)
5855
{
56+
uint32_t tmp;
5957
NVIC_DisableIRQ(UART_IRQn);
6058

6159
// The baudrate calculations require the UART to be clocked as SystemCoreClock
62-
CGU_EntityConnect(CGU_CLKSRC_PLL1, CGU_BASE_UART0);
63-
CGU_EnableEntity(CGU_BASE_UART0, ENABLE);
60+
tmp = LPC_CGU->BASE_UART0_CLK & ~(0x0F << 24); // clear CLK_SEL.
61+
LPC_CGU->BASE_UART0_CLK = tmp
62+
| (0x01 << 11) // AUTOBLOCK: 0=Disabled, 1=Enabled.
63+
| (0x09 << 24) // CLK_SEL = PLL1.
64+
;
65+
66+
LPC_CGU->BASE_UART0_CLK &= ~1; // PD: 0=Power Up.
67+
6468
scu_pinmux(2, 0, UART_RX_TX, FUNC1); /* P2_0: U0_TXD */
6569
scu_pinmux(2, 1, UART_RX_TX, FUNC1); /* P2_1: U0_RXD */
6670

0 commit comments

Comments
 (0)