lpc176x: Move enable_peripheral_clock to main.c

Move and rename function to enable_pclock() - in keeping with other
ARM ports.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor
2019-01-04 10:58:50 -05:00
parent 8f7fc4e6a9
commit a40df4b6f7
9 changed files with 32 additions and 23 deletions

View File

@@ -38,6 +38,27 @@ DECL_INIT(watchdog_init);
* misc functions
****************************************************************/
// Check if a peripheral clock has been enabled
int
is_enabled_pclock(uint32_t pclk)
{
return !!(LPC_SC->PCONP & (1<<pclk));
}
// Enable a peripheral clock
void
enable_pclock(uint32_t pclk)
{
LPC_SC->PCONP |= 1<<pclk;
if (pclk < 16) {
uint32_t shift = pclk * 2;
LPC_SC->PCLKSEL0 = (LPC_SC->PCLKSEL0 & ~(0x3<<shift)) | (0x1<<shift);
} else {
uint32_t shift = (pclk - 16) * 2;
LPC_SC->PCLKSEL1 = (LPC_SC->PCLKSEL1 & ~(0x3<<shift)) | (0x1<<shift);
}
}
void
command_reset(uint32_t *args)
{