[PATCH 1/1] GPIO_BBB Resistor mode support

Ketul Shah ketulshah1993 at gmail.com
Fri Aug 21 12:25:46 UTC 2015


---
 c/src/lib/libbsp/arm/beagle/gpio/bbb-gpio.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/c/src/lib/libbsp/arm/beagle/gpio/bbb-gpio.c b/c/src/lib/libbsp/arm/beagle/gpio/bbb-gpio.c
index 8cf690f..41535cd 100644
--- a/c/src/lib/libbsp/arm/beagle/gpio/bbb-gpio.c
+++ b/c/src/lib/libbsp/arm/beagle/gpio/bbb-gpio.c
@@ -269,8 +269,28 @@ rtems_status_code rtems_gpio_bsp_set_resistor_mode(
   uint32_t pin,
   rtems_gpio_pull_mode mode
 ) {
-  /* TODO: Add support for setting up resistor moode */
-  return RTEMS_NOT_DEFINED;
+  /* If control module offset mapping is not defined 
+   * then function exists silently.
+   */
+  if (gpio_pad_conf[bank][pin] == CONF_NOT_DEFINED){
+    return RTEMS_SUCCESSFUL;
+  }
+  /* Set control signal. */
+  switch ( mode ) {
+    case PULL_UP:
+      mmio_set(bbb_conf_reg(bank, pin), BBB_PU_EN);
+      break;
+    case PULL_DOWN:
+      mmio_clear(bbb_conf_reg(bank, pin), ~BBB_PUDDIS);
+      break;
+    case NO_PULL_RESISTOR:
+      mmio_clear(bbb_conf_reg(bank, pin), ~BBB_PUDDIS);
+      break;
+    default:
+      return RTEMS_UNSATISFIED;
+  }
+
+  return RTEMS_SUCCESSFUL;
 }
 
 rtems_vector_number rtems_gpio_bsp_get_vector(uint32_t bank)
-- 
1.9.1



More information about the devel mailing list