diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2011-11-08 10:39:46 +0000 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2011-11-08 10:39:46 +0000 |
commit | 4a6cc2a4b35e2cb069cb273b7e098366c7bae059 (patch) | |
tree | b08f1c8e32e76029b8442e1ab27e173a3565009b /c/src/lib/libbsp/arm/lpc24xx/misc/system-clocks.c | |
parent | 2011-11-08 Sebastian Huber <sebastian.huber@embedded-brains.de> (diff) | |
download | rtems-4a6cc2a4b35e2cb069cb273b7e098366c7bae059.tar.bz2 |
2011-11-08 Sebastian Huber <sebastian.huber@embedded-brains.de>
* include/lpc17xx.h: New file.
* Makefile.am, preinstall.am: Reflect change above. Update due to API
changes.
* configure.ac, console/console-config.c, include/bsp.h, include/io.h,
include/irq.h, include/lcd.h, include/lpc-clock-config.h,
include/lpc24xx.h, include/start-config.h, irq/irq-dispatch.c,
irq/irq.c, misc/bspidle.c, misc/io.c, misc/lcd.c, misc/restart.c,
misc/system-clocks.c, ssp/ssp.c, startup/bspreset.c,
startup/bspstart.c, startup/bspstarthooks.c,
startup/start-config-emc-dynamic.c, startup/start-config-emc-static.c,
startup/start-config-pinsel.c: Basic support for LPC17XX. New memory
configurations for W9825G2JB75I, IS42S32800B, and SST39VF3201.
Diffstat (limited to 'c/src/lib/libbsp/arm/lpc24xx/misc/system-clocks.c')
-rw-r--r-- | c/src/lib/libbsp/arm/lpc24xx/misc/system-clocks.c | 92 |
1 files changed, 50 insertions, 42 deletions
diff --git a/c/src/lib/libbsp/arm/lpc24xx/misc/system-clocks.c b/c/src/lib/libbsp/arm/lpc24xx/misc/system-clocks.c index df554be646..30adcf2ba5 100644 --- a/c/src/lib/libbsp/arm/lpc24xx/misc/system-clocks.c +++ b/c/src/lib/libbsp/arm/lpc24xx/misc/system-clocks.c @@ -7,15 +7,19 @@ */ /* - * Copyright (c) 2008 - * Embedded Brains GmbH - * Obere Lagerstr. 30 - * D-82178 Puchheim - * Germany - * rtems@embedded-brains.de + * Copyright (c) 2008-2011 embedded brains GmbH. All rights reserved. * - * The license and distribution terms for this file may be found in the file - * LICENSE in this distribution or at http://www.rtems.com/license/LICENSE. + * embedded brains GmbH + * Obere Lagerstr. 30 + * 82178 Puchheim + * Germany + * <rtems@embedded-brains.de> + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ */ #include <bsp.h> @@ -62,7 +66,7 @@ void lpc24xx_timer_initialize(void) void lpc24xx_micro_seconds_delay(unsigned us) { unsigned start = lpc24xx_timer(); - unsigned delay = us * (LPC24XX_CCLK / 1000000); + unsigned delay = us * (LPC24XX_PCLK / 1000000); unsigned elapsed = 0; do { @@ -72,46 +76,50 @@ void lpc24xx_micro_seconds_delay(unsigned us) unsigned lpc24xx_pllclk(void) { - unsigned clksrc = GET_CLKSRCSEL_CLKSRC(CLKSRCSEL); - unsigned pllinclk = 0; - unsigned pllclk = 0; - - /* Get PLL input frequency */ - switch (clksrc) { - case 0: - pllinclk = LPC24XX_OSCILLATOR_INTERNAL; - break; - case 1: - pllinclk = LPC24XX_OSCILLATOR_MAIN; - break; - case 2: - pllinclk = LPC24XX_OSCILLATOR_RTC; - break; - default: - return 0; - } - - /* Get PLL output frequency */ - if ((PLLSTAT & PLLSTAT_PLLC) != 0) { - uint32_t pllcfg = PLLCFG; - unsigned n = GET_PLLCFG_NSEL(pllcfg) + 1; - unsigned m = GET_PLLCFG_MSEL(pllcfg) + 1; - - pllclk = (pllinclk / n) * 2 * m; - } else { - pllclk = pllinclk; - } + #ifdef ARM_MULTILIB_ARCH_V4 + unsigned clksrc = GET_CLKSRCSEL_CLKSRC(CLKSRCSEL); + unsigned pllinclk = 0; + unsigned pllclk = 0; + + /* Get PLL input frequency */ + switch (clksrc) { + case 0: + pllinclk = LPC24XX_OSCILLATOR_INTERNAL; + break; + case 1: + pllinclk = LPC24XX_OSCILLATOR_MAIN; + break; + case 2: + pllinclk = LPC24XX_OSCILLATOR_RTC; + break; + default: + return 0; + } + + /* Get PLL output frequency */ + if ((PLLSTAT & PLLSTAT_PLLC) != 0) { + uint32_t pllcfg = PLLCFG; + unsigned n = GET_PLLCFG_NSEL(pllcfg) + 1; + unsigned m = GET_PLLCFG_MSEL(pllcfg) + 1; + + pllclk = (pllinclk / n) * 2 * m; + } else { + pllclk = pllinclk; + } + #endif return pllclk; } unsigned lpc24xx_cclk(void) { - /* Get PLL output frequency */ - unsigned pllclk = lpc24xx_pllclk(); + #ifdef ARM_MULTILIB_ARCH_V4 + /* Get PLL output frequency */ + unsigned pllclk = lpc24xx_pllclk(); - /* Get CPU frequency */ - unsigned cclk = pllclk / (GET_CCLKCFG_CCLKSEL(CCLKCFG) + 1); + /* Get CPU frequency */ + unsigned cclk = pllclk / (GET_CCLKCFG_CCLKSEL(CCLKCFG) + 1); + #endif return cclk; } |