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/10/10 19:06:25 UTC

[1/5] incubator-mynewt-core git commit: stm32f4xx; add parameter to hal_init_gpio_af() to control whether GPIO is set as OD or not.

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop b7e14d961 -> ec1af7e76


stm32f4xx; add parameter to hal_init_gpio_af() to control whether
GPIO is set as OD or not.


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/ea57fe17
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/ea57fe17
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/ea57fe17

Branch: refs/heads/develop
Commit: ea57fe178d4949b1846f72a47b94e4775a8af952
Parents: b7e14d9
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Mon Oct 10 11:56:34 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon Oct 10 11:56:34 2016 -0700

----------------------------------------------------------------------
 hw/mcu/stm/stm32f4xx/include/mcu/stm32f4_bsp.h | 4 +---
 hw/mcu/stm/stm32f4xx/src/hal_gpio.c            | 8 ++++++--
 2 files changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ea57fe17/hw/mcu/stm/stm32f4xx/include/mcu/stm32f4_bsp.h
----------------------------------------------------------------------
diff --git a/hw/mcu/stm/stm32f4xx/include/mcu/stm32f4_bsp.h b/hw/mcu/stm/stm32f4xx/include/mcu/stm32f4_bsp.h
index e238286..91364df 100644
--- a/hw/mcu/stm/stm32f4xx/include/mcu/stm32f4_bsp.h
+++ b/hw/mcu/stm/stm32f4xx/include/mcu/stm32f4_bsp.h
@@ -39,12 +39,10 @@ struct stm32f4_uart_cfg {
     IRQn_Type suc_irqn;				/* NVIC IRQn */
 };
 
-const struct stm32f4_uart_cfg *bsp_uart_config(int port);
-
 /*
  * Internal API for stm32f4xx mcu specific code.
  */
-int hal_gpio_init_af(int pin, uint8_t af_type, enum gpio_pull pull);
+int hal_gpio_init_af(int pin, uint8_t af_type, enum gpio_pull pull, uint8_t od);
 
 struct hal_flash;
 extern struct hal_flash stm32f4_flash_dev;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ea57fe17/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 9fcc3bd..696d569 100644
--- a/hw/mcu/stm/stm32f4xx/src/hal_gpio.c
+++ b/hw/mcu/stm/stm32f4xx/src/hal_gpio.c
@@ -479,11 +479,15 @@ int hal_gpio_init_out(int pin, int val)
  * Configure the specified pin for AF.
  */
 int
-hal_gpio_init_af(int pin, uint8_t af_type, enum gpio_pull pull)
+hal_gpio_init_af(int pin, uint8_t af_type, enum gpio_pull pull, uint8_t od)
 {
     GPIO_InitTypeDef gpio;
 
-    gpio.Mode = GPIO_MODE_AF_PP;
+    if (!od) {
+        gpio.Mode = GPIO_MODE_AF_PP;
+    } else {
+        gpio.Mode = GPIO_MODE_AF_OD;
+    }
     gpio.Speed = GPIO_SPEED_HIGH;
     gpio.Pull = pull;
     gpio.Alternate = af_type;


[2/5] incubator-mynewt-core git commit: stm32f4xx; HAL I2C driver

Posted by ma...@apache.org.
stm32f4xx; HAL I2C driver


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/6b7140db
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/6b7140db
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/6b7140db

Branch: refs/heads/develop
Commit: 6b7140dbc58b5d228b57f286d9c659d3733bc4b3
Parents: ea57fe1
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Mon Oct 10 11:58:12 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon Oct 10 11:58:12 2016 -0700

----------------------------------------------------------------------
 .../include/mcu/stm32f4xx_mynewt_hal.h          |  11 +-
 hw/mcu/stm/stm32f4xx/src/hal_i2c.c              | 210 +++++++------------
 2 files changed, 85 insertions(+), 136 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6b7140db/hw/mcu/stm/stm32f4xx/include/mcu/stm32f4xx_mynewt_hal.h
----------------------------------------------------------------------
diff --git a/hw/mcu/stm/stm32f4xx/include/mcu/stm32f4xx_mynewt_hal.h b/hw/mcu/stm/stm32f4xx/include/mcu/stm32f4xx_mynewt_hal.h
index 343fc4a..5a4659d 100644
--- a/hw/mcu/stm/stm32f4xx/include/mcu/stm32f4xx_mynewt_hal.h
+++ b/hw/mcu/stm/stm32f4xx/include/mcu/stm32f4xx_mynewt_hal.h
@@ -49,9 +49,14 @@ int hal_gpio_init_stm(int pin, GPIO_InitTypeDef *cfg);
 int hal_gpio_deinit_stm(int pin, GPIO_InitTypeDef *cfg);
 
 struct stm32f4_hal_i2c_cfg {
-    int sda_pin;
-    int scl_pin;
-    I2C_InitTypeDef *i2c_settings;
+    I2C_TypeDef *hic_i2c;
+    volatile uint32_t *hic_rcc_reg;		/* RCC register to modify */
+    uint32_t hic_rcc_dev;			/* RCC device ID */
+    uint8_t hic_pin_sda;
+    uint8_t hic_pin_scl;
+    uint8_t hic_pin_af;
+    uint8_t hic_10bit;
+    uint32_t hic_speed;
 };
 
 struct stm32f4_hal_spi_cfg {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6b7140db/hw/mcu/stm/stm32f4xx/src/hal_i2c.c
----------------------------------------------------------------------
diff --git a/hw/mcu/stm/stm32f4xx/src/hal_i2c.c b/hw/mcu/stm/stm32f4xx/src/hal_i2c.c
index b11244b..1dad92a 100644
--- a/hw/mcu/stm/stm32f4xx/src/hal_i2c.c
+++ b/hw/mcu/stm/stm32f4xx/src/hal_i2c.c
@@ -17,213 +17,157 @@
  * under the License.
  */
 
-#include <hal/hal_i2c.h>
-#include <hal/hal_gpio.h>
-
 #include <string.h>
-#include <errno.h>
-
+#include <stdlib.h>
 #include <assert.h>
 
+#include <syscfg/syscfg.h>
+
+#include <hal/hal_i2c.h>
+#include <hal/hal_gpio.h>
+
 #include "stm32f4xx.h"
 #include "stm32f4xx_hal_dma.h"
 #include "stm32f4xx_hal_i2c.h"
 #include "stm32f4xx_hal_gpio.h"
 #include "stm32f4xx_hal_rcc.h"
 #include "mcu/stm32f4xx_mynewt_hal.h"
+#include "mcu/stm32f4_bsp.h"
+
+#define HAL_I2C_MAX_DEVS	3
 
-#define STM32F4_HAL_I2C_TIMEOUT (1000)
+#define I2C_ADDRESS 		0xae
 
 struct stm32f4_hal_i2c {
-    I2C_HandleTypeDef handle;
+    I2C_HandleTypeDef hid_handle;
+    int hid_locked;
 };
 
-#define STM32_HAL_I2C_MAX (3)
-
-#ifdef I2C1
-struct stm32f4_hal_i2c hal_i2c1;
-#else
-#define __HAL_RCC_I2C1_CLK_ENABLE()
+#if MYNEWT_VAL(I2C_0)
+static struct stm32f4_hal_i2c i2c0;
 #endif
-
-#ifdef I2C2
-struct stm32f4_hal_i2c hal_i2c2;
-#else
-#define __HAL_RCC_I2C2_CLK_ENABLE()
+#if MYNEWT_VAL(I2C_1)
+static struct stm32f4_hal_i2c i2c1;
 #endif
-
-#ifdef I2C3
-struct stm32f4_hal_i2c hal_i2c3;
-#else
-#define __HAL_RCC_I2C3_CLK_ENABLE()
+#if MYNEWT_VAL(I2C_2)
+static struct stm32f4_hal_i2c i2c2;
 #endif
 
-static const struct stm32f4_hal_i2c *stm32f4_hal_i2cs[STM32_HAL_I2C_MAX] = {
-#ifdef I2C1
-        &hal_i2c1,
+static struct stm32f4_hal_i2c *hal_i2c_devs[HAL_I2C_MAX_DEVS] = {
+#if MYNEWT_VAL(I2C_0)
+    &i2c0,
 #else
-        NULL,
+    NULL,
 #endif
-#ifdef I2C2
-        &hal_i2c2,
+#if MYNEWT_VAL(I2C_1)
+    &i2c1,
 #else
-        NULL,
+    NULL,
 #endif
-#ifdef I2C3
-        &hal_i2c3,
+#if MYNEWT_VAL(I2C_2)
+    &i2c2,
 #else
-        NULL,
+    NULL,
 #endif
 };
 
-#define STM32_HAL_I2C_RESOLVE(__n, __v)                          \
-    if ((__n) >= STM32_HAL_I2C_MAX) {                            \
-        rc = EINVAL;                                             \
-        goto err;                                                \
-    }                                                            \
-    (__v) = (struct stm32f4_hal_i2c *) stm32f4_hal_i2cs[(__n)];  \
-    if ((__v) == NULL) {                                         \
-        rc = EINVAL;                                             \
-        goto err;                                                \
-    }
-
 int
 hal_i2c_init(uint8_t i2c_num, void *usercfg)
 {
-    GPIO_InitTypeDef pcf;
-    struct stm32f4_hal_i2c *i2c;
-    struct stm32f4_hal_i2c_cfg *cfg;
+    struct stm32f4_hal_i2c_cfg *cfg = (struct stm32f4_hal_i2c_cfg *)usercfg;
+    struct stm32f4_hal_i2c *dev;
+    I2C_InitTypeDef *init;
     int rc;
 
-    STM32_HAL_I2C_RESOLVE(i2c_num, i2c);
-
-    cfg = (struct stm32f4_hal_i2c_cfg *) usercfg;
-    assert(cfg != NULL);
-
-    pcf.Mode = GPIO_MODE_OUTPUT_PP;
-    pcf.Pull = GPIO_PULLUP;
-    pcf.Speed = GPIO_SPEED_FREQ_MEDIUM;
-    pcf.Alternate = 0;
-
-    rc = hal_gpio_init_stm(cfg->sda_pin, &pcf);
-    if (rc != 0) {
-        goto err;
+    if (i2c_num > HAL_I2C_MAX_DEVS || !(dev = hal_i2c_devs[i2c_num])) {
+        return -1;
     }
 
-    rc = hal_gpio_init_stm(cfg->scl_pin, &pcf);
-    if (rc != 0) {
-        goto err;
+    init = &dev->hid_handle.Init;
+    dev->hid_handle.Instance = cfg->hic_i2c;
+    init->ClockSpeed = cfg->hic_speed;
+    if (cfg->hic_10bit) {
+        init->AddressingMode = I2C_ADDRESSINGMODE_10BIT;
+    } else {
+        init->AddressingMode = I2C_ADDRESSINGMODE_7BIT;
     }
-
-    /* Configure I2C */
-    switch (i2c_num) {
-        case 0:
-            __HAL_RCC_I2C1_CLK_ENABLE();
-            break;
-        case 1:
-            __HAL_RCC_I2C2_CLK_ENABLE();
-            break;
-        case 2:
-            __HAL_RCC_I2C3_CLK_ENABLE();
-            break;
-        default:
-            rc = EINVAL;
-            goto err;
+    init->OwnAddress1 = I2C_ADDRESS;
+    init->OwnAddress2 = 0xFE;
+
+    /*
+     * Configure GPIO pins for I2C.
+     * Enable clock routing for I2C.
+     */
+    rc = hal_gpio_init_af(cfg->hic_pin_sda, cfg->hic_pin_af, GPIO_PULL_UP, 1);
+    if (rc) {
+        goto err;
     }
-
-    if (cfg->i2c_settings != NULL) {
-        /* Copy user defined settings onto the handle */
-        memcpy(&i2c->handle.Init, cfg->i2c_settings, sizeof(I2C_InitTypeDef));
-    } else {
-        /* Initialize with default I2C Settings */
+    rc = hal_gpio_init_af(cfg->hic_pin_scl, cfg->hic_pin_af, GPIO_PULL_UP, 1);
+    if (rc) {
+        goto err;
     }
-
-    rc = HAL_I2C_Init(&i2c->handle);
-    if (rc != 0) {
+    *cfg->hic_rcc_reg |= cfg->hic_rcc_dev;
+    rc = HAL_I2C_Init(&dev->hid_handle);
+    if (rc) {
         goto err;
     }
 
-    return (0);
+    return 0;
 err:
-    return (rc);
+    *cfg->hic_rcc_reg &= ~cfg->hic_rcc_dev;
+    return rc;
 }
 
 int
-hal_i2c_master_write(uint8_t i2c_num, struct hal_i2c_master_data *pdata,
+hal_i2c_master_write(uint8_t i2c_num, struct hal_i2c_master_data *data,
   uint32_t timo)
 {
-    struct stm32f4_hal_i2c *i2c;
-    int rc;
-
-    STM32_HAL_I2C_RESOLVE(i2c_num, i2c);
+    struct stm32f4_hal_i2c *dev;
 
-    rc = HAL_I2C_Master_Transmit_IT(&i2c->handle, pdata->address, pdata->buffer,
-            pdata->len);
-    if (rc != 0) {
-        goto err;
+    if (i2c_num > HAL_I2C_MAX_DEVS || !(dev = hal_i2c_devs[i2c_num])) {
+        return -1;
     }
 
-    return (0);
-err:
-    return (rc);
+    return HAL_I2C_Master_Transmit(&dev->hid_handle, data->address << 1,
+      data->buffer, data->len, timo);
 }
 
 int
 hal_i2c_master_read(uint8_t i2c_num, struct hal_i2c_master_data *pdata,
   uint32_t timo)
 {
-    struct stm32f4_hal_i2c *i2c;
-    int rc;
+    struct stm32f4_hal_i2c *dev;
 
-    STM32_HAL_I2C_RESOLVE(i2c_num, i2c);
-
-    rc = HAL_I2C_Master_Receive_IT(&i2c->handle, pdata->address, pdata->buffer,
-            pdata->len);
-    if (rc != 0) {
-        goto err;
+    if (i2c_num > HAL_I2C_MAX_DEVS || !(dev = hal_i2c_devs[i2c_num])) {
+        return -1;
     }
 
-    return (0);
-err:
-    return (rc);
+    return HAL_I2C_Master_Receive(&dev->hid_handle, pdata->address << 1,
+      pdata->buffer, pdata->len, timo);
 }
 
 int
 hal_i2c_master_begin(uint8_t i2c_num)
 {
-    return (0);
+    return 0;
 }
 
 int
 hal_i2c_master_end(uint8_t i2c_num)
 {
-    struct stm32f4_hal_i2c *i2c;
-    int rc;
-
-    STM32_HAL_I2C_RESOLVE(i2c_num, i2c);
-
-    i2c->handle.Instance->CR1 |= I2C_CR1_STOP;
-
-    return (0);
-err:
-    return (rc);
+    return 0;
 }
 
 int
 hal_i2c_master_probe(uint8_t i2c_num, uint8_t address, uint32_t timo)
 {
-    struct stm32f4_hal_i2c *i2c;
+    struct stm32f4_hal_i2c *dev;
     int rc;
 
-    STM32_HAL_I2C_RESOLVE(i2c_num, i2c);
-
-    rc = HAL_I2C_IsDeviceReady(&i2c->handle, address, 1,
-            STM32F4_HAL_I2C_TIMEOUT);
-    if (rc != 0) {
-        goto err;
+    if (i2c_num > HAL_I2C_MAX_DEVS || !(dev = hal_i2c_devs[i2c_num])) {
+        return -1;
     }
 
-    return (0);
-err:
-    return (rc);
+    rc = HAL_I2C_IsDeviceReady(&dev->hid_handle, address, 1, timo);
+    return rc;
 }


[5/5] incubator-mynewt-core git commit: stm32f4xx hal; add HAL_GetTick() to support timeouts when using SDK calls.

Posted by ma...@apache.org.
stm32f4xx hal; add HAL_GetTick() to support timeouts when using SDK calls.


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/ec1af7e7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/ec1af7e7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/ec1af7e7

Branch: refs/heads/develop
Commit: ec1af7e766e23a1574feb248ce40ec721a5cda4c
Parents: df6e098
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Mon Oct 10 12:03:25 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon Oct 10 12:04:31 2016 -0700

----------------------------------------------------------------------
 hw/mcu/stm/stm32f4xx/src/hal_system.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ec1af7e7/hw/mcu/stm/stm32f4xx/src/hal_system.c
----------------------------------------------------------------------
diff --git a/hw/mcu/stm/stm32f4xx/src/hal_system.c b/hw/mcu/stm/stm32f4xx/src/hal_system.c
index 8f6a876..68b1a76 100644
--- a/hw/mcu/stm/stm32f4xx/src/hal_system.c
+++ b/hw/mcu/stm/stm32f4xx/src/hal_system.c
@@ -18,6 +18,7 @@
  */
 
 #include <mcu/cortex_m4.h>
+#include <os/os.h>
 #include "hal/hal_system.h"
 #include "stm32f4xx_hal_def.h"
 
@@ -44,7 +45,7 @@ system_debugger_connected(void)
 uint32_t
 HAL_GetTick(void)
 {
-    return 0;
+    return os_time_get();
 }
 
 HAL_StatusTypeDef


[3/5] incubator-mynewt-core git commit: stm32f4xx uart; add extra parameter to hal_gpio_init_af().

Posted by ma...@apache.org.
stm32f4xx uart; add extra parameter to hal_gpio_init_af().


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/9cbb93c3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/9cbb93c3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/9cbb93c3

Branch: refs/heads/develop
Commit: 9cbb93c31964d77ec140d963f7a9be93edc6ab96
Parents: 6b7140d
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Mon Oct 10 11:59:28 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon Oct 10 11:59:28 2016 -0700

----------------------------------------------------------------------
 hw/mcu/stm/stm32f4xx/src/hal_uart.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9cbb93c3/hw/mcu/stm/stm32f4xx/src/hal_uart.c
----------------------------------------------------------------------
diff --git a/hw/mcu/stm/stm32f4xx/src/hal_uart.c b/hw/mcu/stm/stm32f4xx/src/hal_uart.c
index 5b3280c..bd248ec 100644
--- a/hw/mcu/stm/stm32f4xx/src/hal_uart.c
+++ b/hw/mcu/stm/stm32f4xx/src/hal_uart.c
@@ -351,11 +351,11 @@ hal_uart_config(int port, int32_t baudrate, uint8_t databits, uint8_t stopbits,
 
     *cfg->suc_rcc_reg |= cfg->suc_rcc_dev;
 
-    hal_gpio_init_af(cfg->suc_pin_tx, cfg->suc_pin_af, 0);
-    hal_gpio_init_af(cfg->suc_pin_rx, cfg->suc_pin_af, 0);
+    hal_gpio_init_af(cfg->suc_pin_tx, cfg->suc_pin_af, 0, 0);
+    hal_gpio_init_af(cfg->suc_pin_rx, cfg->suc_pin_af, 0, 0);
     if (flow_ctl == HAL_UART_FLOW_CTL_RTS_CTS) {
-        hal_gpio_init_af(cfg->suc_pin_rts, cfg->suc_pin_af, 0);
-        hal_gpio_init_af(cfg->suc_pin_cts, cfg->suc_pin_af, 0);
+        hal_gpio_init_af(cfg->suc_pin_rts, cfg->suc_pin_af, 0, 0);
+        hal_gpio_init_af(cfg->suc_pin_cts, cfg->suc_pin_af, 0, 0);
     }
 
     u->u_regs = cfg->suc_uart;


[4/5] incubator-mynewt-core git commit: olimex_stm32-e407_devboard; add i2c device going to UEXT connector.

Posted by ma...@apache.org.
olimex_stm32-e407_devboard; add i2c device going to UEXT connector.


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/df6e098e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/df6e098e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/df6e098e

Branch: refs/heads/develop
Commit: df6e098e48d7adcb11fe04e45060bda7c8491ca8
Parents: 9cbb93c
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Mon Oct 10 12:02:45 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon Oct 10 12:02:45 2016 -0700

----------------------------------------------------------------------
 hw/bsp/olimex_stm32-e407_devboard/pkg.yml      |  1 +
 hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c | 22 +++++++++++++++++++++
 hw/bsp/olimex_stm32-e407_devboard/syscfg.yml   | 10 ++++++++++
 3 files changed, 33 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/df6e098e/hw/bsp/olimex_stm32-e407_devboard/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/olimex_stm32-e407_devboard/pkg.yml b/hw/bsp/olimex_stm32-e407_devboard/pkg.yml
index e465d16..76d2892 100644
--- a/hw/bsp/olimex_stm32-e407_devboard/pkg.yml
+++ b/hw/bsp/olimex_stm32-e407_devboard/pkg.yml
@@ -32,6 +32,7 @@ pkg.cflags:
     - '-DSTM32F407xx'
     - '-DHAL_ADC_MODULE_ENABLED'
     - '-DHAL_DMA_MODULE_ENABLED'
+    - -DHAL_I2C_MODULE_ENABLED
 
 pkg.deps:
     - boot/bootutil

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/df6e098e/hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c b/hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c
index 1b3e9f6..69ece50 100644
--- a/hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c
+++ b/hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c
@@ -31,9 +31,14 @@
 
 #include "bsp/bsp.h"
 #include "syscfg/syscfg.h"
+#include "mcu/stm32f4xx_mynewt_hal.h"
+#include "stm32f407xx.h"
+#include "stm32f4xx_hal_gpio_ex.h"
 #include "stm32f4xx_hal_dma.h"
 #include "stm32f4xx_hal_adc.h"
+#include "stm32f4xx_hal_adc.h"
 #include <adc_stm32f4/adc_stm32f4.h>
+#include <hal/hal_i2c.h>
 
 static struct uart_dev hal_uart0;
 
@@ -246,6 +251,19 @@ struct adc_chan_config adc3_chan4_config = STM32F4_ADC3_DEFAULT_SAC;
 struct stm32f4_adc_dev_cfg adc3_config = STM32F4_ADC3_DEFAULT_CONFIG;
 #endif
 
+#if MYNEWT_VAL(I2C_0)
+static struct stm32f4_hal_i2c_cfg i2c_cfg0 = {
+    .hic_i2c = I2C1,
+    .hic_rcc_reg = &RCC->APB1ENR,
+    .hic_rcc_dev = RCC_APB1ENR_I2C1EN,
+    .hic_pin_sda = 16 + 9,		/* PB9 */
+    .hic_pin_scl = 16 + 8,		/* PB8 */
+    .hic_pin_af = GPIO_AF4_I2C1,
+    .hic_10bit = 0,
+    .hic_speed = 100000			/* 100kHz */
+};
+#endif
+
 void
 bsp_init(void)
 {
@@ -273,5 +291,9 @@ bsp_init(void)
     assert(rc == 0);
 #endif
 
+#if MYNEWT_VAL(I2C_0)
+    rc = hal_i2c_init(0, &i2c_cfg0);
+    assert(rc == 0);
+#endif
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/df6e098e/hw/bsp/olimex_stm32-e407_devboard/syscfg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/olimex_stm32-e407_devboard/syscfg.yml b/hw/bsp/olimex_stm32-e407_devboard/syscfg.yml
index f5c564d..ac9e982 100644
--- a/hw/bsp/olimex_stm32-e407_devboard/syscfg.yml
+++ b/hw/bsp/olimex_stm32-e407_devboard/syscfg.yml
@@ -21,6 +21,16 @@ syscfg.defs:
         description: 'TBD'
         value:  0
 
+    I2C_0:
+        description: 'I2C0'
+        value: 0
+    I2C_1:
+        description: 'I2C1'
+        value: 0
+    I2C_0:
+        description: 'I2C2'
+        value: 0
+
     SPI_MASTER:
         description: 'TBD'
         value:  0