[rtems commit] bsp/lpc24xx: Add lpc24xx_module_is_enabled()

Sebastian Huber sebh at rtems.org
Fri Jun 15 13:58:31 UTC 2012


Module:    rtems
Branch:    master
Commit:    4e0755c81b038d0e0fff2c5a10e40e1963296950
Changeset: http://git.rtems.org/rtems/commit/?id=4e0755c81b038d0e0fff2c5a10e40e1963296950

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Jun 15 09:51:14 2012 +0200

bsp/lpc24xx: Add lpc24xx_module_is_enabled()

---

 c/src/lib/libbsp/arm/lpc24xx/include/io.h |    2 ++
 c/src/lib/libbsp/arm/lpc24xx/misc/io.c    |   24 ++++++++++++++++++++++++
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/c/src/lib/libbsp/arm/lpc24xx/include/io.h b/c/src/lib/libbsp/arm/lpc24xx/include/io.h
index 03ae472..f77b447 100644
--- a/c/src/lib/libbsp/arm/lpc24xx/include/io.h
+++ b/c/src/lib/libbsp/arm/lpc24xx/include/io.h
@@ -147,6 +147,8 @@ rtems_status_code lpc24xx_module_disable(
   lpc24xx_module module
 );
 
+bool lpc24xx_module_is_enabled(lpc24xx_module module);
+
 rtems_status_code lpc24xx_gpio_config(
   unsigned index,
   lpc24xx_gpio_settings settings
diff --git a/c/src/lib/libbsp/arm/lpc24xx/misc/io.c b/c/src/lib/libbsp/arm/lpc24xx/misc/io.c
index 1141b71..ad74164 100644
--- a/c/src/lib/libbsp/arm/lpc24xx/misc/io.c
+++ b/c/src/lib/libbsp/arm/lpc24xx/misc/io.c
@@ -327,6 +327,30 @@ rtems_status_code lpc24xx_module_disable(
   );
 }
 
+bool lpc24xx_module_is_enabled(lpc24xx_module module)
+{
+  bool enabled = false;
+
+  if ((unsigned) module < LPC24XX_MODULE_COUNT) {
+    bool has_power = lpc24xx_module_table [module].power;
+
+    if (has_power) {
+      unsigned index = lpc24xx_module_table [module].index;
+      #ifdef ARM_MULTILIB_ARCH_V4
+        uint32_t pconp = PCONP;
+      #else
+        uint32_t pconp = LPC17XX_SCB.pconp;
+      #endif
+
+      enabled = (pconp & (1U << index)) != 0;
+    } else {
+      enabled = true;
+    }
+  }
+
+  return enabled;
+}
+
 typedef rtems_status_code (*lpc24xx_pin_visitor)(
   #ifdef ARM_MULTILIB_ARCH_V4
     volatile uint32_t *pinsel,




More information about the vc mailing list