You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/11/28 20:36:25 UTC

[1/2] incubator-mynewt-core git commit: Fix setting value of GPIO output only after init

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop d36a40391 -> ea3347b27


Fix setting value of GPIO output only after init


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/48e6147d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/48e6147d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/48e6147d

Branch: refs/heads/develop
Commit: 48e6147d7b76f6a3dbe89c5fa91f16217f36f5a4
Parents: d36a403
Author: Fabio Utzig <ut...@utzig.org>
Authored: Mon Nov 28 09:54:41 2016 -0200
Committer: Fabio Utzig <ut...@utzig.org>
Committed: Mon Nov 28 09:54:41 2016 -0200

----------------------------------------------------------------------
 hw/mcu/stm/stm32f4xx/src/hal_gpio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/48e6147d/hw/mcu/stm/stm32f4xx/src/hal_gpio.c
----------------------------------------------------------------------
diff --git a/hw/mcu/stm/stm32f4xx/src/hal_gpio.c b/hw/mcu/stm/stm32f4xx/src/hal_gpio.c
index d8bbd46..6769ce6 100644
--- a/hw/mcu/stm/stm32f4xx/src/hal_gpio.c
+++ b/hw/mcu/stm/stm32f4xx/src/hal_gpio.c
@@ -469,11 +469,11 @@ int hal_gpio_init_out(int pin, int val)
     init_cfg.Speed = GPIO_SPEED_HIGH;
     init_cfg.Alternate = 0;
 
-    hal_gpio_write(pin, val);
     rc = hal_gpio_init_stm(pin, &init_cfg);
     if (rc) {
         return rc;
     }
+    hal_gpio_write(pin, val);
     return 0;
 }
 


[2/2] incubator-mynewt-core git commit: This closes #126.

Posted by ma...@apache.org.
This closes #126.

Initialize RCC => set output value => set mode


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/ea3347b2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/ea3347b2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/ea3347b2

Branch: refs/heads/develop
Commit: ea3347b272a3a91edb846161a5a9e38638571d86
Parents: 48e6147
Author: Fabio Utzig <ut...@utzig.org>
Authored: Mon Nov 28 18:24:49 2016 -0200
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon Nov 28 12:33:41 2016 -0800

----------------------------------------------------------------------
 hw/mcu/stm/stm32f4xx/src/hal_gpio.c | 33 +++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ea3347b2/hw/mcu/stm/stm32f4xx/src/hal_gpio.c
----------------------------------------------------------------------
diff --git a/hw/mcu/stm/stm32f4xx/src/hal_gpio.c b/hw/mcu/stm/stm32f4xx/src/hal_gpio.c
index 6769ce6..44c2eb8 100644
--- a/hw/mcu/stm/stm32f4xx/src/hal_gpio.c
+++ b/hw/mcu/stm/stm32f4xx/src/hal_gpio.c
@@ -385,7 +385,7 @@ hal_gpio_init_stm(int pin, GPIO_InitTypeDef *cfg)
     mcu_pin_mask = GPIO_MASK(pin);
     cfg->Pin = mcu_pin_mask;
 
-    /* Enable the GPIO clockl */
+    /* Enable the GPIO clock */
     hal_gpio_clk_enable(port);
 
     /* Initialize pin as an input, setting proper mode */
@@ -461,19 +461,30 @@ hal_gpio_init_in(int pin, hal_gpio_pull_t pull)
  */
 int hal_gpio_init_out(int pin, int val)
 {
-    int rc;
-    GPIO_InitTypeDef init_cfg;
-
-    init_cfg.Mode = GPIO_MODE_OUTPUT_PP;
-    init_cfg.Pull = GPIO_NOPULL;
-    init_cfg.Speed = GPIO_SPEED_HIGH;
-    init_cfg.Alternate = 0;
+    GPIO_InitTypeDef cfg;
+    int port;
 
-    rc = hal_gpio_init_stm(pin, &init_cfg);
-    if (rc) {
-        return rc;
+    /* Is this a valid pin? */
+    port = GPIO_PORT(pin);
+    if (port >= HAL_GPIO_NUM_PORTS) {
+        return -1;
     }
+
+    /* Enable the GPIO clock */
+    hal_gpio_clk_enable(port);
+
+    /* Write initial output value */
     hal_gpio_write(pin, val);
+
+    cfg.Pin = GPIO_MASK(pin);
+    cfg.Mode = GPIO_MODE_OUTPUT_PP;
+    cfg.Pull = GPIO_NOPULL;
+    cfg.Speed = GPIO_SPEED_HIGH;
+    cfg.Alternate = 0;
+
+    /* Initialize pin as an output, setting proper mode */
+    HAL_GPIO_Init(portmap[port], &cfg);
+
     return 0;
 }