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/21 20:50:57 UTC

incubator-mynewt-core git commit: Remove bsp_get_refmv().

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop fcd1198b5 -> c81b7fe8a


Remove bsp_get_refmv().


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

Branch: refs/heads/develop
Commit: c81b7fe8a98cce7fde4368691dc69c535c1b901e
Parents: fcd1198
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Fri Oct 21 13:49:47 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Oct 21 13:49:47 2016 -0700

----------------------------------------------------------------------
 hw/bsp/arduino_primo_nrf52/src/hal_bsp.c        |   6 -
 hw/bsp/arduino_primo_nrf52/src/os_bsp.c         |   6 +-
 hw/bsp/bmd300eval/src/os_bsp.c                  |   6 +-
 hw/bsp/nrf51dk-16kbram/src/hal_bsp.c            |  36 -
 hw/bsp/nrf51dk/src/hal_bsp.c                    |  36 -
 hw/bsp/nrf52dk/nrf52dk_debug.sh                 |   1 +
 hw/bsp/nrf52dk/src/hal_bsp.c                    |   6 -
 hw/bsp/nrf52dk/src/os_bsp.c                     |   6 +-
 hw/bsp/rb-nano2/src/hal_bsp.c                   |   6 -
 .../adc/adc_nrf51/include/adc_nrf51/adc_nrf51.h |   6 +
 hw/drivers/adc/adc_nrf51/src/adc_nrf51.c        |  23 +-
 .../adc/adc_nrf52/include/adc_nrf52/adc_nrf52.h |   4 +
 hw/drivers/adc/adc_nrf52/src/adc_nrf52.c        |  14 +-
 .../include/stm32f4_eth/stm32f4_eth.h           |  27 +
 .../include/stm32f4_eth/stm32f4_eth_cfg.h       |  32 +
 hw/drivers/lwip/stm32f4_eth/pkg.yml             |  33 +
 hw/drivers/lwip/stm32f4_eth/src/stm32f4_eth.c   | 740 +++++++++++++++++++
 hw/hal/include/hal/hal_bsp.h                    |   2 -
 18 files changed, 873 insertions(+), 117 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c81b7fe8/hw/bsp/arduino_primo_nrf52/src/hal_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/arduino_primo_nrf52/src/hal_bsp.c b/hw/bsp/arduino_primo_nrf52/src/hal_bsp.c
index dedccee..4e64ddc 100644
--- a/hw/bsp/arduino_primo_nrf52/src/hal_bsp.c
+++ b/hw/bsp/arduino_primo_nrf52/src/hal_bsp.c
@@ -56,12 +56,6 @@ hal_bsp_core_dump(int *area_cnt)
     return dump_cfg;
 }
 
-uint16_t
-bsp_get_refmv(void *cfgdata)
-{
-    return (2800);
-}
-
 int
 hal_bsp_power_state(int state)
 {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c81b7fe8/hw/bsp/arduino_primo_nrf52/src/os_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/arduino_primo_nrf52/src/os_bsp.c b/hw/bsp/arduino_primo_nrf52/src/os_bsp.c
index dd5a666..444281b 100644
--- a/hw/bsp/arduino_primo_nrf52/src/os_bsp.c
+++ b/hw/bsp/arduino_primo_nrf52/src/os_bsp.c
@@ -72,10 +72,8 @@ static const struct uart_bitbang_conf os_bsp_uart1_cfg = {
 
 #if MYNEWT_VAL(ADC_0)
 static struct adc_dev os_bsp_adc0;
-static nrf_drv_saadc_config_t os_bsp_adc0_config = {
-    .resolution         = MYNEWT_VAL(ADC_0_RESOLUTION),
-    .oversample         = MYNEWT_VAL(ADC_0_OVERSAMPLE),
-    .interrupt_priority = MYNEWT_VAL(ADC_0_INTERRUPT_PRIORITY),
+static struct nrf52_adc_dev_cfg os_bsp_adc0_config = {
+    .nadc_refmv = 2800
 };
 #endif
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c81b7fe8/hw/bsp/bmd300eval/src/os_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/bmd300eval/src/os_bsp.c b/hw/bsp/bmd300eval/src/os_bsp.c
index 0470bc4..4c0b709 100644
--- a/hw/bsp/bmd300eval/src/os_bsp.c
+++ b/hw/bsp/bmd300eval/src/os_bsp.c
@@ -69,10 +69,8 @@ static const struct uart_bitbang_conf os_bsp_uart1_cfg = {
 
 #if MYNEWT_VAL(ADC_0)
 static struct adc_dev os_bsp_adc0;
-static nrf_drv_saadc_config_t os_bsp_adc0_config = {
-    .resolution         = MYNEWT_VAL(ADC_0_RESOLUTION),
-    .oversample         = MYNEWT_VAL(ADC_0_OVERSAMPLE),
-    .interrupt_priority = MYNEWT_VAL(ADC_0_INTERRUPT_PRIORITY),
+static struct nrf52_adc_dev_cfg os_bsp_adc0_config = {
+    .nadc_refmv = 2800
 };
 #endif
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c81b7fe8/hw/bsp/nrf51dk-16kbram/src/hal_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51dk-16kbram/src/hal_bsp.c b/hw/bsp/nrf51dk-16kbram/src/hal_bsp.c
index 07edafa..95526a2 100644
--- a/hw/bsp/nrf51dk-16kbram/src/hal_bsp.c
+++ b/hw/bsp/nrf51dk-16kbram/src/hal_bsp.c
@@ -56,42 +56,6 @@ hal_bsp_core_dump(int *area_cnt)
     return dump_cfg;
 }
 
-uint16_t
-bsp_get_refmv(void *cfgdata)
-{
-    uint16_t refmv;
-    nrf_drv_adc_channel_config_t *cc;
-    nrf_adc_config_reference_t cref;
-
-    cc = (nrf_drv_adc_channel_config_t *) cfgdata;
-    cref = cc->reference | (cc->external_reference << ADC_CONFIG_EXTREFSEL_Pos);
-    switch (cref) {
-        case NRF_ADC_CONFIG_REF_VBG:
-            refmv = 1200;
-            break;
-/* XXX: fill these out if using an external reference */
-#if 0
-        case NRF_ADC_CONFIG_REF_EXT_REF0:
-            refmv = XXX;
-            break;
-        case NRF_ADC_CONFIG_REF_EXT_REF1:
-            refmv = YYY;
-            break;
-#endif
-        case NRF_ADC_CONFIG_REF_SUPPLY_ONE_HALF:
-            refmv = 2800 / 2;
-            break;
-        case NRF_ADC_CONFIG_REF_SUPPLY_ONE_THIRD:
-            refmv = 2800 / 3;
-            break;
-        default:
-            refmv = 0;
-            break;
-    }
-
-    return refmv;
-}
-
 int
 hal_bsp_power_state(int state)
 {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c81b7fe8/hw/bsp/nrf51dk/src/hal_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51dk/src/hal_bsp.c b/hw/bsp/nrf51dk/src/hal_bsp.c
index 07edafa..95526a2 100644
--- a/hw/bsp/nrf51dk/src/hal_bsp.c
+++ b/hw/bsp/nrf51dk/src/hal_bsp.c
@@ -56,42 +56,6 @@ hal_bsp_core_dump(int *area_cnt)
     return dump_cfg;
 }
 
-uint16_t
-bsp_get_refmv(void *cfgdata)
-{
-    uint16_t refmv;
-    nrf_drv_adc_channel_config_t *cc;
-    nrf_adc_config_reference_t cref;
-
-    cc = (nrf_drv_adc_channel_config_t *) cfgdata;
-    cref = cc->reference | (cc->external_reference << ADC_CONFIG_EXTREFSEL_Pos);
-    switch (cref) {
-        case NRF_ADC_CONFIG_REF_VBG:
-            refmv = 1200;
-            break;
-/* XXX: fill these out if using an external reference */
-#if 0
-        case NRF_ADC_CONFIG_REF_EXT_REF0:
-            refmv = XXX;
-            break;
-        case NRF_ADC_CONFIG_REF_EXT_REF1:
-            refmv = YYY;
-            break;
-#endif
-        case NRF_ADC_CONFIG_REF_SUPPLY_ONE_HALF:
-            refmv = 2800 / 2;
-            break;
-        case NRF_ADC_CONFIG_REF_SUPPLY_ONE_THIRD:
-            refmv = 2800 / 3;
-            break;
-        default:
-            refmv = 0;
-            break;
-    }
-
-    return refmv;
-}
-
 int
 hal_bsp_power_state(int state)
 {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c81b7fe8/hw/bsp/nrf52dk/nrf52dk_debug.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52dk/nrf52dk_debug.sh b/hw/bsp/nrf52dk/nrf52dk_debug.sh
index 56b009f..31a1b2c 100755
--- a/hw/bsp/nrf52dk/nrf52dk_debug.sh
+++ b/hw/bsp/nrf52dk/nrf52dk_debug.sh
@@ -51,6 +51,7 @@ echo "target remote localhost:3333" > $GDB_CMD_FILE
 # Whether target should be reset or not
 if [ ! -z "$RESET" ]; then
     echo "mon reset" >> $GDB_CMD_FILE
+    echo "si" >> $GDB_CMD_FILE
 fi
 if [ $SPLIT_ELF_PRESENT -eq 1 ]; then
     # TODO -- this magic number 0x42000 is the location of the second image slot.

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c81b7fe8/hw/bsp/nrf52dk/src/hal_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52dk/src/hal_bsp.c b/hw/bsp/nrf52dk/src/hal_bsp.c
index 222a421..621413e 100644
--- a/hw/bsp/nrf52dk/src/hal_bsp.c
+++ b/hw/bsp/nrf52dk/src/hal_bsp.c
@@ -52,12 +52,6 @@ hal_bsp_core_dump(int *area_cnt)
     return dump_cfg;
 }
 
-uint16_t
-bsp_get_refmv(void *cfgdata)
-{
-    return (2800);
-}
-
 int
 hal_bsp_power_state(int state)
 {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c81b7fe8/hw/bsp/nrf52dk/src/os_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52dk/src/os_bsp.c b/hw/bsp/nrf52dk/src/os_bsp.c
index ad09e38..bbac752 100644
--- a/hw/bsp/nrf52dk/src/os_bsp.c
+++ b/hw/bsp/nrf52dk/src/os_bsp.c
@@ -70,10 +70,8 @@ static const struct uart_bitbang_conf os_bsp_uart1_cfg = {
 
 #if MYNEWT_VAL(ADC_0)
 static struct adc_dev os_bsp_adc0;
-static nrf_drv_saadc_config_t os_bsp_adc0_config = {
-    .resolution         = MYNEWT_VAL(ADC_0_RESOLUTION),
-    .oversample         = MYNEWT_VAL(ADC_0_OVERSAMPLE),
-    .interrupt_priority = MYNEWT_VAL(ADC_0_INTERRUPT_PRIORITY),
+static struct nrf52_adc_dev_cfg os_bsp_adc0_config = {
+    .nadc_refmv = 2800
 };
 #endif
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c81b7fe8/hw/bsp/rb-nano2/src/hal_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/rb-nano2/src/hal_bsp.c b/hw/bsp/rb-nano2/src/hal_bsp.c
index 222a421..621413e 100644
--- a/hw/bsp/rb-nano2/src/hal_bsp.c
+++ b/hw/bsp/rb-nano2/src/hal_bsp.c
@@ -52,12 +52,6 @@ hal_bsp_core_dump(int *area_cnt)
     return dump_cfg;
 }
 
-uint16_t
-bsp_get_refmv(void *cfgdata)
-{
-    return (2800);
-}
-
 int
 hal_bsp_power_state(int state)
 {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c81b7fe8/hw/drivers/adc/adc_nrf51/include/adc_nrf51/adc_nrf51.h
----------------------------------------------------------------------
diff --git a/hw/drivers/adc/adc_nrf51/include/adc_nrf51/adc_nrf51.h b/hw/drivers/adc/adc_nrf51/include/adc_nrf51/adc_nrf51.h
index e70ac88..d681404 100644
--- a/hw/drivers/adc/adc_nrf51/include/adc_nrf51/adc_nrf51.h
+++ b/hw/drivers/adc/adc_nrf51/include/adc_nrf51/adc_nrf51.h
@@ -29,6 +29,12 @@
 extern "C" {
 #endif
 
+struct nrf51_adc_dev_cfg {
+    uint16_t nadc_refmv0;	/* reference mV in AREF0 */
+    uint16_t nadc_refmv1;	/* reference mV in AREF1 */
+    uint16_t nadc_refmv_vdd;	/* reference mV in VDD */
+};
+
 int nrf51_adc_dev_init(struct os_dev *, void *);
 
 #ifdef __cplusplus

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c81b7fe8/hw/drivers/adc/adc_nrf51/src/adc_nrf51.c
----------------------------------------------------------------------
diff --git a/hw/drivers/adc/adc_nrf51/src/adc_nrf51.c b/hw/drivers/adc/adc_nrf51/src/adc_nrf51.c
index cf57de6..129fb4a 100644
--- a/hw/drivers/adc/adc_nrf51/src/adc_nrf51.c
+++ b/hw/drivers/adc/adc_nrf51/src/adc_nrf51.c
@@ -28,6 +28,8 @@
 #include <nrf_drv_adc.h>
 #include <app_error.h>
 
+#include "adc_nrf51/adc_nrf51.h"
+
 /**
  * Weak symbol, this is defined in Nordic drivers but not exported.
  * Needed for NVIC_SetVector().
@@ -42,13 +44,13 @@ struct nrf51_adc_stats {
 };
 static struct nrf51_adc_stats nrf51_adc_stats;
 
-struct adc_dev *global_adc_dev;
+static struct adc_dev *global_adc_dev;
 
-nrf_adc_config_t adc_cfg;
-nrf_drv_adc_config_t *global_adc_config;
+static nrf_drv_adc_config_t *global_adc_config;
+static struct nrf51_adc_dev_cfg *init_adc_config;
 
-struct adc_chan_config nrf51_adc_chans[NRF_ADC_CHANNEL_COUNT];
-nrf_drv_adc_channel_t *nrf_adc_chan;
+static struct adc_chan_config nrf51_adc_chans[NRF_ADC_CHANNEL_COUNT];
+static nrf_drv_adc_channel_t *nrf_adc_chan;
 
 static void
 nrf51_adc_event_handler(const nrf_drv_adc_evt_t *event)
@@ -211,16 +213,16 @@ nrf51_adc_configure_channel(struct adc_dev *dev, uint8_t cnum,
             refmv = 1200; /* 1.2V for NRF51 */
             break;
         case NRF_ADC_CONFIG_REF_EXT_REF0:
-            refmv = bsp_get_refmv(cc_cfg);
+            refmv = init_adc_config->nadc_refmv0;
             break;
         case NRF_ADC_CONFIG_REF_EXT_REF1:
-            refmv = bsp_get_refmv(cc_cfg);
+            refmv = init_adc_config->nadc_refmv1;
             break;
         case NRF_ADC_CONFIG_REF_SUPPLY_ONE_HALF:
-            refmv = bsp_get_refmv(cc_cfg) / 2;
+            refmv = init_adc_config->nadc_refmv_vdd / 2;
             break;
         case NRF_ADC_CONFIG_REF_SUPPLY_ONE_THIRD:
-            refmv = bsp_get_refmv(cc_cfg) / 3;
+            refmv = init_adc_config->nadc_refmv_vdd / 3;
             break;
         default:
             assert(0);
@@ -382,6 +384,9 @@ nrf51_adc_dev_init(struct os_dev *odev, void *arg)
 
     OS_DEV_SETHANDLERS(odev, nrf51_adc_open, nrf51_adc_close);
 
+    assert(init_adc_config == NULL || init_adc_config == arg);
+    init_adc_config = arg;
+
     af = &dev->ad_funcs;
 
     af->af_configure_channel = nrf51_adc_configure_channel;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c81b7fe8/hw/drivers/adc/adc_nrf52/include/adc_nrf52/adc_nrf52.h
----------------------------------------------------------------------
diff --git a/hw/drivers/adc/adc_nrf52/include/adc_nrf52/adc_nrf52.h b/hw/drivers/adc/adc_nrf52/include/adc_nrf52/adc_nrf52.h
index 5325d96..6aadb4c 100644
--- a/hw/drivers/adc/adc_nrf52/include/adc_nrf52/adc_nrf52.h
+++ b/hw/drivers/adc/adc_nrf52/include/adc_nrf52/adc_nrf52.h
@@ -29,6 +29,10 @@
 extern "C" {
 #endif
 
+struct nrf52_adc_dev_cfg {
+    uint16_t nadc_refmv;		/* reference VDD in mV */
+};
+
 int nrf52_adc_dev_init(struct os_dev *, void *);
 
 #ifdef __cplusplus

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c81b7fe8/hw/drivers/adc/adc_nrf52/src/adc_nrf52.c
----------------------------------------------------------------------
diff --git a/hw/drivers/adc/adc_nrf52/src/adc_nrf52.c b/hw/drivers/adc/adc_nrf52/src/adc_nrf52.c
index d167175..5054a9f 100644
--- a/hw/drivers/adc/adc_nrf52/src/adc_nrf52.c
+++ b/hw/drivers/adc/adc_nrf52/src/adc_nrf52.c
@@ -30,6 +30,8 @@
 #include <nrf_drv_saadc.h>
 #include <app_error.h>
 
+#include "adc_nrf52/adc_nrf52.h"
+
 /**
  * Weak symbol, this is defined in Nordic drivers but not exported.
  * Needed for NVIC_SetVector().
@@ -42,10 +44,11 @@ struct nrf52_saadc_stats {
 };
 static struct nrf52_saadc_stats nrf52_saadc_stats;
 
-struct adc_dev *global_adc_dev;
-nrf_drv_saadc_config_t *global_adc_config;
+static struct adc_dev *global_adc_dev;
+static nrf_drv_saadc_config_t *global_adc_config;
+static struct nrf52_adc_dev_cfg *init_adc_config;
 
-uint8_t nrf52_adc_chans[NRF_SAADC_CHANNEL_COUNT * sizeof(struct adc_chan_config)];
+static uint8_t nrf52_adc_chans[NRF_SAADC_CHANNEL_COUNT * sizeof(struct adc_chan_config)];
 
 static void
 nrf52_saadc_event_handler(const nrf_drv_saadc_evt_t *event)
@@ -211,7 +214,7 @@ nrf52_adc_configure_channel(struct adc_dev *dev, uint8_t cnum,
             refmv = 600; /* 0.6V for NRF52 */
             break;
         case NRF_SAADC_REFERENCE_VDD4:
-            refmv = bsp_get_refmv(NULL) / 4;
+            refmv = init_adc_config->nadc_refmv / 4;
             break;
         default:
             assert(0);
@@ -380,6 +383,9 @@ nrf52_adc_dev_init(struct os_dev *odev, void *arg)
 
     OS_DEV_SETHANDLERS(odev, nrf52_adc_open, nrf52_adc_close);
 
+    assert(init_adc_config == NULL || init_adc_config == arg);
+    init_adc_config = arg;
+
     af = &dev->ad_funcs;
 
     af->af_configure_channel = nrf52_adc_configure_channel;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c81b7fe8/hw/drivers/lwip/stm32f4_eth/include/stm32f4_eth/stm32f4_eth.h
----------------------------------------------------------------------
diff --git a/hw/drivers/lwip/stm32f4_eth/include/stm32f4_eth/stm32f4_eth.h b/hw/drivers/lwip/stm32f4_eth/include/stm32f4_eth/stm32f4_eth.h
new file mode 100644
index 0000000..e2487da
--- /dev/null
+++ b/hw/drivers/lwip/stm32f4_eth/include/stm32f4_eth/stm32f4_eth.h
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef __STM32F4_ETH_H__
+#define __STM32F4_ETH_H__
+
+int stm32f4_eth_init(void *cfg);
+int stm32f4_eth_open(void);
+int stm32f4_eth_close(void);
+
+#endif /* __STM32F4_ETH_H__ */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c81b7fe8/hw/drivers/lwip/stm32f4_eth/include/stm32f4_eth/stm32f4_eth_cfg.h
----------------------------------------------------------------------
diff --git a/hw/drivers/lwip/stm32f4_eth/include/stm32f4_eth/stm32f4_eth_cfg.h b/hw/drivers/lwip/stm32f4_eth/include/stm32f4_eth/stm32f4_eth_cfg.h
new file mode 100644
index 0000000..c18f77d
--- /dev/null
+++ b/hw/drivers/lwip/stm32f4_eth/include/stm32f4_eth/stm32f4_eth_cfg.h
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef __STM32F4_ETH_CFG_H__
+#define __STM32F4_ETH_CFG_H__
+
+/*
+ * BSP specific ethernet settings.
+ */
+#define STM32F4_MAX_PORTS	9
+
+struct stm32f4_eth_cfg {
+    /* Mask of pins from ports A-I to use */
+    uint32_t sec_port_mask[STM32F4_MAX_PORTS];
+};
+#endif /* __STM32F4_ETH_CFG_H__ */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c81b7fe8/hw/drivers/lwip/stm32f4_eth/pkg.yml
----------------------------------------------------------------------
diff --git a/hw/drivers/lwip/stm32f4_eth/pkg.yml b/hw/drivers/lwip/stm32f4_eth/pkg.yml
new file mode 100644
index 0000000..606bf1f
--- /dev/null
+++ b/hw/drivers/lwip/stm32f4_eth/pkg.yml
@@ -0,0 +1,33 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+pkg.name: hw/drivers/lwip/stm32f4_eth
+pkg.description: Driver for STM43F4 on-chip ethernet
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
+pkg.keywords:
+    - ip
+    - lwip
+    - ethernet
+pkg.deps:
+    - hw/hal
+    - hw/mcu/stm/stm32f4xx
+    - net/ip/lwip_base
+pkg.req_apis: 
+

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c81b7fe8/hw/drivers/lwip/stm32f4_eth/src/stm32f4_eth.c
----------------------------------------------------------------------
diff --git a/hw/drivers/lwip/stm32f4_eth/src/stm32f4_eth.c b/hw/drivers/lwip/stm32f4_eth/src/stm32f4_eth.c
new file mode 100755
index 0000000..54c15d3
--- /dev/null
+++ b/hw/drivers/lwip/stm32f4_eth/src/stm32f4_eth.c
@@ -0,0 +1,740 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <hal/hal_gpio.h>
+#include <bsp/cmsis_nvic.h>
+
+#include <stm32f4xx.h>
+#include <stm32f4xx_hal_gpio.h>
+#include <stm32f4xx_hal_eth.h>
+#include <stm32f4xx_hal_rcc.h>
+#include <mcu/stm32f4_bsp.h>
+
+#include <netif/etharp.h>
+#include <netif/ethernet.h>
+#include <lwip/ethip6.h>
+#include <string.h>
+
+#include "stm32f4_eth/stm32f4_eth.h"
+#include "stm32f4_eth/stm32f4_eth_cfg.h"
+
+#if 0
+/* Private typedef -----------------------------------------------------------*/
+/* Private define ------------------------------------------------------------*/
+/* Network interface name */
+#define IFNAME0 's'
+#define IFNAME1 't'
+
+/* Private macro -------------------------------------------------------------*/
+/* Private variables ---------------------------------------------------------*/
+#if defined ( __ICCARM__ ) /*!< IAR Compiler */
+  #pragma data_alignment=4   
+#endif
+__ALIGN_BEGIN ETH_DMADescTypeDef  DMARxDscrTab[ETH_RXBUFNB] __ALIGN_END;/* Ethernet Rx MA Descriptor */
+
+#if defined ( __ICCARM__ ) /*!< IAR Compiler */
+  #pragma data_alignment=4   
+#endif
+__ALIGN_BEGIN ETH_DMADescTypeDef  DMATxDscrTab[ETH_TXBUFNB] __ALIGN_END;/* Ethernet Tx DMA Descriptor */
+
+#if defined ( __ICCARM__ ) /*!< IAR Compiler */
+  #pragma data_alignment=4   
+#endif
+__ALIGN_BEGIN uint8_t Rx_Buff[ETH_RXBUFNB][ETH_RX_BUF_SIZE] __ALIGN_END; /* Ethernet Receive Buffer */
+
+#if defined ( __ICCARM__ ) /*!< IAR Compiler */
+  #pragma data_alignment=4   
+#endif
+__ALIGN_BEGIN uint8_t Tx_Buff[ETH_TXBUFNB][ETH_TX_BUF_SIZE] __ALIGN_END; /* Ethernet Transmit Buffer */
+
+ETH_HandleTypeDef EthHandle;
+
+/* Private function prototypes -----------------------------------------------*/
+/* Private functions ---------------------------------------------------------*/
+/*******************************************************************************
+                       Ethernet MSP Routines
+*******************************************************************************/
+/**
+  * @brief  Initializes the ETH MSP.
+  * @param  heth: ETH handle
+  * @retval None
+  */
+void HAL_ETH_MspInit(ETH_HandleTypeDef *heth)
+{ 
+  GPIO_InitTypeDef GPIO_InitStructure;
+  
+  /* Enable GPIOs clocks */
+  __HAL_RCC_GPIOA_CLK_ENABLE();
+  __HAL_RCC_GPIOB_CLK_ENABLE();
+  __HAL_RCC_GPIOC_CLK_ENABLE();
+  __HAL_RCC_GPIOF_CLK_ENABLE();
+  __HAL_RCC_GPIOG_CLK_ENABLE();
+  __HAL_RCC_GPIOH_CLK_ENABLE();
+  __HAL_RCC_GPIOI_CLK_ENABLE(); 
+
+/* Ethernet pins configuration ************************************************/
+   /*
+        ETH_MDIO -------------------------> PA2
+        ETH_MDC --------------------------> PC1
+        ETH_PPS_OUT ----------------------> PB5
+        ETH_MII_CRS ----------------------> PH2
+        ETH_MII_COL ----------------------> PH3
+        ETH_MII_RX_ER --------------------> PI10
+        ETH_MII_RXD2 ---------------------> PH6
+        ETH_MII_RXD3 ---------------------> PH7
+        ETH_MII_TX_CLK -------------------> PC3
+        ETH_MII_TXD2 ---------------------> PC2
+        ETH_MII_TXD3 ---------------------> PB8
+        ETH_MII_RX_CLK/ETH_RMII_REF_CLK---> PA1
+        ETH_MII_RX_DV/ETH_RMII_CRS_DV ----> PA7
+        ETH_MII_RXD0/ETH_RMII_RXD0 -------> PC4
+        ETH_MII_RXD1/ETH_RMII_RXD1 -------> PC5
+        ETH_MII_TX_EN/ETH_RMII_TX_EN -----> PG11
+        ETH_MII_TXD0/ETH_RMII_TXD0 -------> PG13
+        ETH_MII_TXD1/ETH_RMII_TXD1 -------> PG14
+                                                  */
+
+  /* Configure PA1, PA2 , PA7 */
+  GPIO_InitStructure.Pin = GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_7;
+  GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
+  GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;
+  GPIO_InitStructure.Pull = GPIO_NOPULL; 
+  GPIO_InitStructure.Alternate = GPIO_AF11_ETH;
+  HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
+
+  /* Configure PB5 and PB8 */
+  GPIO_InitStructure.Pin = GPIO_PIN_5 | GPIO_PIN_8;
+  HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);
+
+  /* Configure PC1, PC2, PC3, PC4 and PC5 */
+  GPIO_InitStructure.Pin = GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5;
+  HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
+                             
+  /* Configure PG11, PG14 and PG13 */
+  GPIO_InitStructure.Pin =  GPIO_PIN_11 | GPIO_PIN_13 | GPIO_PIN_14;
+  HAL_GPIO_Init(GPIOG, &GPIO_InitStructure);
+
+  /* Configure PH2, PH3, PH6, PH7 */
+  GPIO_InitStructure.Pin = GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_6 | GPIO_PIN_7;
+  HAL_GPIO_Init(GPIOH, &GPIO_InitStructure);
+
+  /* Configure PI10 */
+  GPIO_InitStructure.Pin = GPIO_PIN_10;
+  HAL_GPIO_Init(GPIOI, &GPIO_InitStructure);
+  
+  /* Enable ETHERNET clock  */
+  __HAL_RCC_ETH_CLK_ENABLE();
+  
+  if (heth->Init.MediaInterface == ETH_MEDIA_INTERFACE_MII)
+  {
+    /* Output HSE clock (25MHz) on MCO pin (PA8) to clock the PHY */
+    HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_1);
+  }
+}
+
+/*******************************************************************************
+                       LL Driver Interface ( LwIP stack --> ETH) 
+*******************************************************************************/
+/**
+  * In this function, the hardware should be initialized.
+  * Called from ethernetif_init().
+  *
+  * @param netif the already initialized lwip network interface structure
+  *        for this ethernetif
+  */
+static void low_level_init(struct netif *netif)
+{ 
+  uint32_t regvalue = 0;
+  uint8_t macaddress[6]= { MAC_ADDR0, MAC_ADDR1, MAC_ADDR2, MAC_ADDR3, MAC_ADDR4, MAC_ADDR5 };
+
+  EthHandle.Instance = ETH;  
+  EthHandle.Init.MACAddr = macaddress;
+  EthHandle.Init.AutoNegotiation = ETH_AUTONEGOTIATION_ENABLE;
+  EthHandle.Init.Speed = ETH_SPEED_100M;
+  EthHandle.Init.DuplexMode = ETH_MODE_FULLDUPLEX;
+  EthHandle.Init.MediaInterface = ETH_MEDIA_INTERFACE_MII;
+  EthHandle.Init.RxMode = ETH_RXPOLLING_MODE;
+  EthHandle.Init.ChecksumMode = ETH_CHECKSUM_BY_HARDWARE;
+  EthHandle.Init.PhyAddress = DP83848_PHY_ADDRESS;
+  
+  /* configure ethernet peripheral (GPIOs, clocks, MAC, DMA) */
+  if (HAL_ETH_Init(&EthHandle) == HAL_OK)
+  {
+    /* Set netif link flag */
+    netif->flags |= NETIF_FLAG_LINK_UP;
+  }
+  
+  /* Initialize Tx Descriptors list: Chain Mode */
+  HAL_ETH_DMATxDescListInit(&EthHandle, DMATxDscrTab, &Tx_Buff[0][0], ETH_TXBUFNB);
+     
+  /* Initialize Rx Descriptors list: Chain Mode  */
+  HAL_ETH_DMARxDescListInit(&EthHandle, DMARxDscrTab, &Rx_Buff[0][0], ETH_RXBUFNB);
+
+  /* set MAC hardware address length */
+  netif->hwaddr_len = ETHARP_HWADDR_LEN;
+  
+  /* set MAC hardware address */
+  netif->hwaddr[0] =  MAC_ADDR0;
+  netif->hwaddr[1] =  MAC_ADDR1;
+  netif->hwaddr[2] =  MAC_ADDR2;
+  netif->hwaddr[3] =  MAC_ADDR3;
+  netif->hwaddr[4] =  MAC_ADDR4;
+  netif->hwaddr[5] =  MAC_ADDR5;
+  
+  /* maximum transfer unit */
+  netif->mtu = 1500;
+  
+  /* device capabilities */
+  /* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
+  netif->flags |= NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP;
+  
+  /* Enable MAC and DMA transmission and reception */
+  HAL_ETH_Start(&EthHandle);
+  
+  /**** Configure PHY to generate an interrupt when Eth Link state changes ****/
+  /* Read Register Configuration */
+  HAL_ETH_ReadPHYRegister(&EthHandle, PHY_MICR, &regvalue);
+  
+  regvalue |= (PHY_MICR_INT_EN | PHY_MICR_INT_OE);
+
+  /* Enable Interrupts */
+  HAL_ETH_WritePHYRegister(&EthHandle, PHY_MICR, regvalue );
+  
+  /* Read Register Configuration */
+  HAL_ETH_ReadPHYRegister(&EthHandle, PHY_MISR, &regvalue);
+  
+  regvalue |= PHY_MISR_LINK_INT_EN;
+    
+  /* Enable Interrupt on change of link status */
+  HAL_ETH_WritePHYRegister(&EthHandle, PHY_MISR, regvalue);
+}
+
+/**
+  * This function should do the actual transmission of the packet. The packet is
+  * contained in the pbuf that is passed to the function. This pbuf
+  * might be chained.
+  *
+  * @param netif the lwip network interface structure for this ethernetif
+  * @param p the MAC packet to send (e.g. IP packet including MAC addresses and type)
+  * @return ERR_OK if the packet could be sent
+  *         an err_t value if the packet couldn't be sent
+  *
+  * @note Returning ERR_MEM here if a DMA queue of your MAC is full can lead to
+  *       strange results. You might consider waiting for space in the DMA queue
+  *       to become availale since the stack doesn't retry to send a packet
+  *       dropped because of memory failure (except for the TCP timers).
+  */
+static err_t low_level_output(struct netif *netif, struct pbuf *p)
+{
+  err_t errval;
+  struct pbuf *q;
+  uint8_t *buffer = (uint8_t *)(EthHandle.TxDesc->Buffer1Addr);
+  __IO ETH_DMADescTypeDef *DmaTxDesc;
+  uint32_t framelength = 0;
+  uint32_t bufferoffset = 0;
+  uint32_t byteslefttocopy = 0;
+  uint32_t payloadoffset = 0;
+
+  DmaTxDesc = EthHandle.TxDesc;
+  bufferoffset = 0;
+  
+  /* copy frame from pbufs to driver buffers */
+  for(q = p; q != NULL; q = q->next)
+  {
+    /* Is this buffer available? If not, goto error */
+    if((DmaTxDesc->Status & ETH_DMATXDESC_OWN) != (uint32_t)RESET)
+    {
+      errval = ERR_USE;
+      goto error;
+    }
+    
+    /* Get bytes in current lwIP buffer */
+    byteslefttocopy = q->len;
+    payloadoffset = 0;
+    
+    /* Check if the length of data to copy is bigger than Tx buffer size*/
+    while( (byteslefttocopy + bufferoffset) > ETH_TX_BUF_SIZE )
+    {
+      /* Copy data to Tx buffer*/
+      memcpy( (uint8_t*)((uint8_t*)buffer + bufferoffset), (uint8_t*)((uint8_t*)q->payload + payloadoffset), (ETH_TX_BUF_SIZE - bufferoffset) );
+      
+      /* Point to next descriptor */
+      DmaTxDesc = (ETH_DMADescTypeDef *)(DmaTxDesc->Buffer2NextDescAddr);
+      
+      /* Check if the buffer is available */
+      if((DmaTxDesc->Status & ETH_DMATXDESC_OWN) != (uint32_t)RESET)
+      {
+        errval = ERR_USE;
+        goto error;
+      }
+      
+      buffer = (uint8_t *)(DmaTxDesc->Buffer1Addr);
+      
+      byteslefttocopy = byteslefttocopy - (ETH_TX_BUF_SIZE - bufferoffset);
+      payloadoffset = payloadoffset + (ETH_TX_BUF_SIZE - bufferoffset);
+      framelength = framelength + (ETH_TX_BUF_SIZE - bufferoffset);
+      bufferoffset = 0;
+    }
+    
+    /* Copy the remaining bytes */
+    memcpy( (uint8_t*)((uint8_t*)buffer + bufferoffset), (uint8_t*)((uint8_t*)q->payload + payloadoffset), byteslefttocopy );
+    bufferoffset = bufferoffset + byteslefttocopy;
+    framelength = framelength + byteslefttocopy;
+  }
+  
+  /* Prepare transmit descriptors to give to DMA */ 
+  HAL_ETH_TransmitFrame(&EthHandle, framelength);
+  
+  errval = ERR_OK;
+  
+error:
+  
+  /* When Transmit Underflow flag is set, clear it and issue a Transmit Poll Demand to resume transmission */
+  if ((EthHandle.Instance->DMASR & ETH_DMASR_TUS) != (uint32_t)RESET)
+  {
+    /* Clear TUS ETHERNET DMA flag */
+    EthHandle.Instance->DMASR = ETH_DMASR_TUS;
+    
+    /* Resume DMA transmission*/
+    EthHandle.Instance->DMATPDR = 0;
+  }
+  return errval;
+}
+
+/**
+  * Should allocate a pbuf and transfer the bytes of the incoming
+  * packet from the interface into the pbuf.
+  *
+  * @param netif the lwip network interface structure for this ethernetif
+  * @return a pbuf filled with the received packet (including MAC header)
+  *         NULL on memory error
+  */
+static struct pbuf * low_level_input(struct netif *netif)
+{
+  struct pbuf *p = NULL;
+  struct pbuf *q;
+  uint16_t len;
+  uint8_t *buffer;
+  __IO ETH_DMADescTypeDef *dmarxdesc;
+  uint32_t bufferoffset = 0;
+  uint32_t payloadoffset = 0;
+  uint32_t byteslefttocopy = 0;
+  uint32_t i=0;
+  
+  if (HAL_ETH_GetReceivedFrame(&EthHandle) != HAL_OK)
+    return NULL;
+  
+  /* Obtain the size of the packet and put it into the "len" variable. */
+  len = EthHandle.RxFrameInfos.length;
+  buffer = (uint8_t *)EthHandle.RxFrameInfos.buffer;
+  
+  /* We allocate a pbuf chain of pbufs from the Lwip buffer pool */
+  p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);
+  
+  if (p != NULL)
+  {
+    dmarxdesc = EthHandle.RxFrameInfos.FSRxDesc;
+    bufferoffset = 0;
+    for(q = p; q != NULL; q = q->next)
+    {
+      byteslefttocopy = q->len;
+      payloadoffset = 0;
+      
+      /* Check if the length of bytes to copy in current pbuf is bigger than Rx buffer size*/
+      while( (byteslefttocopy + bufferoffset) > ETH_RX_BUF_SIZE )
+      {
+        /* Copy data to pbuf*/
+        memcpy( (u8_t*)((u8_t*)q->payload + payloadoffset), (u8_t*)((u8_t*)buffer + bufferoffset), (ETH_RX_BUF_SIZE - bufferoffset));
+        
+        /* Point to next descriptor */
+        dmarxdesc = (ETH_DMADescTypeDef *)(dmarxdesc->Buffer2NextDescAddr);
+        buffer = (unsigned char *)(dmarxdesc->Buffer1Addr);
+        
+        byteslefttocopy = byteslefttocopy - (ETH_RX_BUF_SIZE - bufferoffset);
+        payloadoffset = payloadoffset + (ETH_RX_BUF_SIZE - bufferoffset);
+        bufferoffset = 0;
+      }
+      /* Copy remaining data in pbuf */
+      memcpy( (u8_t*)((u8_t*)q->payload + payloadoffset), (u8_t*)((u8_t*)buffer + bufferoffset), byteslefttocopy);
+      bufferoffset = bufferoffset + byteslefttocopy;
+    }
+  }
+  
+  dmarxdesc = EthHandle.RxFrameInfos.FSRxDesc;
+  
+  /* Set Own bit in Rx descriptors: gives the buffers back to DMA */
+  for (i=0; i< (EthHandle.RxFrameInfos).SegCount; i++)
+  {  
+    dmarxdesc->Status = ETH_DMARXDESC_OWN;
+    dmarxdesc = (ETH_DMADescTypeDef *)(dmarxdesc->Buffer2NextDescAddr);
+  }
+  
+  /* Clear Segment_Count */
+  (EthHandle.RxFrameInfos).SegCount =0;
+  
+  /* When Rx Buffer unavailable flag is set: clear it and resume reception */
+  if (((EthHandle.Instance)->DMASR & ETH_DMASR_RBUS) != (uint32_t)RESET)  
+  {
+    /* Clear RBUS ETHERNET DMA flag */
+    (EthHandle.Instance)->DMASR = ETH_DMASR_RBUS;
+    /* Resume DMA reception */
+    (EthHandle.Instance)->DMARPDR = 0;
+  }
+  return p;
+}
+
+/**
+  * This function should be called when a packet is ready to be read
+  * from the interface. It uses the function low_level_input() that
+  * should handle the actual reception of bytes from the network
+  * interface. Then the type of the received packet is determined and
+  * the appropriate input function is called.
+  *
+  * @param netif the lwip network interface structure for this ethernetif
+  */
+void ethernetif_input(struct netif *netif)
+{
+  err_t err;
+  struct pbuf *p;
+  
+  /* move received packet into a new pbuf */
+  p = low_level_input(netif);
+    
+  /* no packet could be read, silently ignore this */
+  if (p == NULL) return;
+    
+  /* entry point to the LwIP stack */
+  err = netif->input(p, netif);
+    
+  if (err != ERR_OK)
+  {
+    LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
+    pbuf_free(p);
+    p = NULL;
+  }
+}
+
+/**
+  * Should be called at the beginning of the program to set up the
+  * network interface. It calls the function low_level_init() to do the
+  * actual setup of the hardware.
+  *
+  * This function should be passed as a parameter to netif_add().
+  *
+  * @param netif the lwip network interface structure for this ethernetif
+  * @return ERR_OK if the loopif is initialized
+  *         ERR_MEM if private data couldn't be allocated
+  *         any other err_t on error
+  */
+err_t ethernetif_init(struct netif *netif)
+{
+  LWIP_ASSERT("netif != NULL", (netif != NULL));
+  
+#if LWIP_NETIF_HOSTNAME
+  /* Initialize interface hostname */
+  netif->hostname = "lwip";
+#endif /* LWIP_NETIF_HOSTNAME */
+
+  netif->name[0] = IFNAME0;
+  netif->name[1] = IFNAME1;
+  /* We directly use etharp_output() here to save a function call.
+   * You can instead declare your own function an call etharp_output()
+   * from it if you have to do some checks before sending (e.g. if link
+   * is available...) */
+  netif->output = etharp_output;
+  netif->linkoutput = low_level_output;
+
+  /* initialize the hardware */
+  low_level_init(netif);
+
+  return ERR_OK;
+}
+
+/**
+  * @brief  Returns the current time in milliseconds
+  *         when LWIP_TIMERS == 1 and NO_SYS == 1
+  * @param  None
+  * @retval Time
+  */
+u32_t sys_now(void)
+{
+  return HAL_GetTick();
+}
+
+/**
+  * @brief  This function sets the netif link status.
+  * @param  netif: the network interface
+  * @retval None
+  */
+void ethernetif_set_link(struct netif *netif)
+{
+  uint32_t regvalue = 0;
+  
+  /* Read PHY_MISR*/
+  HAL_ETH_ReadPHYRegister(&EthHandle, PHY_MISR, &regvalue);
+  
+  /* Check whether the link interrupt has occurred or not */
+  if((regvalue & PHY_LINK_INTERRUPT) != (uint16_t)RESET)
+  {
+    /* Read PHY_SR*/
+    HAL_ETH_ReadPHYRegister(&EthHandle, PHY_SR, &regvalue);
+    
+    /* Check whether the link is up or down*/
+    if((regvalue & PHY_LINK_STATUS)!= (uint16_t)RESET)
+    {
+      netif_set_link_up(netif);
+    }
+    else
+    {
+      netif_set_link_down(netif);
+    }
+  }
+}
+
+/**
+  * @brief  Link callback function, this function is called on change of link status
+  *         to update low level driver configuration.
+  * @param  netif: The network interface
+  * @retval None
+  */
+void ethernetif_update_config(struct netif *netif)
+{
+  __IO uint32_t tickstart = 0;
+  uint32_t regvalue = 0;
+  
+  if(netif_is_link_up(netif))
+  { 
+    /* Restart the auto-negotiation */
+    if(EthHandle.Init.AutoNegotiation != ETH_AUTONEGOTIATION_DISABLE)
+    {
+      /* Enable Auto-Negotiation */
+      HAL_ETH_WritePHYRegister(&EthHandle, PHY_BCR, PHY_AUTONEGOTIATION);
+      
+      /* Get tick */
+      tickstart = HAL_GetTick();
+      
+      /* Wait until the auto-negotiation will be completed */
+      do
+      {
+        HAL_ETH_ReadPHYRegister(&EthHandle, PHY_BSR, &regvalue);
+        
+        /* Check for the Timeout ( 1s ) */
+        if((HAL_GetTick() - tickstart ) > 1000)
+        {
+          /* In case of timeout */
+          goto error;
+        }
+        
+      } while (((regvalue & PHY_AUTONEGO_COMPLETE) != PHY_AUTONEGO_COMPLETE));
+      
+      /* Read the result of the auto-negotiation */
+      HAL_ETH_ReadPHYRegister(&EthHandle, PHY_SR, &regvalue);
+      
+      /* Configure the MAC with the Duplex Mode fixed by the auto-negotiation process */
+      if((regvalue & PHY_DUPLEX_STATUS) != (uint32_t)RESET)
+      {
+        /* Set Ethernet duplex mode to Full-duplex following the auto-negotiation */
+        EthHandle.Init.DuplexMode = ETH_MODE_FULLDUPLEX;  
+      }
+      else
+      {
+        /* Set Ethernet duplex mode to Half-duplex following the auto-negotiation */
+        EthHandle.Init.DuplexMode = ETH_MODE_HALFDUPLEX;           
+      }
+      /* Configure the MAC with the speed fixed by the auto-negotiation process */
+      if(regvalue & PHY_SPEED_STATUS)
+      {  
+        /* Set Ethernet speed to 10M following the auto-negotiation */
+        EthHandle.Init.Speed = ETH_SPEED_10M; 
+      }
+      else
+      {   
+        /* Set Ethernet speed to 100M following the auto-negotiation */ 
+        EthHandle.Init.Speed = ETH_SPEED_100M;
+      }
+    }
+    else /* AutoNegotiation Disable */
+    {
+    error :
+      /* Check parameters */
+      assert_param(IS_ETH_SPEED(EthHandle.Init.Speed));
+      assert_param(IS_ETH_DUPLEX_MODE(EthHandle.Init.DuplexMode));
+      
+      /* Set MAC Speed and Duplex Mode to PHY */
+      HAL_ETH_WritePHYRegister(&EthHandle, PHY_BCR, ((uint16_t)(EthHandle.Init.DuplexMode >> 3) |
+                                                     (uint16_t)(EthHandle.Init.Speed >> 1))); 
+    }
+
+    /* ETHERNET MAC Re-Configuration */
+    HAL_ETH_ConfigMAC(&EthHandle, (ETH_MACInitTypeDef *) NULL);
+
+    /* Restart MAC interface */
+    HAL_ETH_Start(&EthHandle);   
+  }
+  else
+  {
+    /* Stop MAC interface */
+    HAL_ETH_Stop(&EthHandle);
+  }
+
+  ethernetif_notify_conn_changed(netif);
+}
+
+/**
+  * @brief  This function notify user about link status changement.
+  * @param  netif: the network interface
+  * @retval None
+  */
+__weak void ethernetif_notify_conn_changed(struct netif *netif)
+{
+  /* NOTE : This is function clould be implemented in user file 
+            when the callback is needed,
+  */  
+}
+#endif
+
+struct stm32f4_eth_state {
+    struct netif nif;
+    ETH_HandleTypeDef st_eth;
+    struct stm32f4_eth_cfg *cfg;
+};
+
+static struct stm32f4_eth_state stm32f4_eth_state;
+
+/*
+ * Hardware configuration. Should be called from BSP init.
+ */
+int
+stm32f4_eth_init(void *cfg)
+{
+    stm32f4_eth_state.cfg = cfg;
+    return 0;
+}
+
+#if LWIP_IGMP
+static err_t
+stm32f4_igmp_mac_filter(struct netif *nif, const ip4_addr_t *group,
+  enum netif_mac_filter_action action)
+{
+    return -1;
+}
+#endif
+
+#if LWIP_IPV6 && LWIP_IPV6_MLD
+static err_t
+stm32f4_mld_mac_filter(struct netif *nif, const ip6_addr_t *group,
+  enum netif_mac_filter_action action)
+{
+    return -1;
+}
+#endif
+
+static err_t
+stm32f4_output(struct netif *nif, struct pbuf *p)
+{
+    return ERR_OK;
+}
+
+static void
+stm32f4_eth_isr(void)
+{
+    HAL_ETH_IRQHandler(&stmref4_eth_State.st_eth);
+}
+
+static err_t
+stm32f4_lwip_init(struct netif *nif)
+{
+    struct stm32f4_eth_state *ses = &stm32f4_eth_state;
+    int i, j;
+    struct stm32f4_eth_cfg *cfg;
+
+    /*
+     * LwIP clears most of these field in netif_add() before calling
+     * this init routine. So we need to fill them in here.
+     */
+    memcpy(nif->name, "st", 2);
+    nif->output = etharp_output;
+#if LWIP_IPV6
+    nif->output_ip6 = ethip6_output;
+#endif
+    nif->linkoutput = stm32f4_output;
+    nif->mtu = 1500;
+    nif->hwaddr_len = ETHARP_HWADDR_LEN;
+    nif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP;
+
+#if LWIP_IGMP
+    nif->flags |= NETIF_FLAG_IGMP;
+    nif->igmp_mac_filter = stm32f4_igmp_mac_filter;
+#endif
+#if LWIP_IPV6 && LWIP_IPV6_MLD
+    nif->flags |= NETIF_FLAG_MLD6;
+    nif->mld_mac_filter = stm32f4_mld_mac_filter;
+#endif
+
+    cfg = ses->cfg;
+
+    /*
+     * Now take the BSP specific HW config and set up the hardware.
+     */
+    for (i = 0; i < STM32F4_MAX_PORTS; i++) {
+        for (j = 0; j < 32; j++) {
+            if ((cfg->sec_port_mask[i] & (1 << j)) == 0) {
+                continue;
+            }
+            hal_gpio_init_af(i * 16 + j, GPIO_AF11_ETH, GPIO_NOPULL);
+        }
+    }
+
+    NVIC_SetVector(ETH_IRQn, (uint32_t)stm32f4_eth_isr);
+    NVIC_EnableIRQ(ETH_IRQn);
+    __HAL_RCC_ETH_CLK_ENABLE();
+
+    ses->st_eth.Instance = ETH;
+    ses->st_eth.Init.MACAddr = { 0, 1, 2, 3, 4, 5 };
+    ses->st_eth.Init.Autonegotiation = ETH_AUTONEGOTIATION_ENABLE;
+    ses->st_eth.Init.Speed = ETH_SPEED_100M;
+    ses->st_eth.Init.DuplexMode = ETH_MODE_FULLDUPLEX;
+    ses->st_eth.Init.PhyAddress = 0;
+    ses->st_eth.Init.RxMode = ETH_RXINTERRUPT_MODE;
+    ses->st_eth.Init.ChecksumMode = ETH_CHECKSUM_BY_HARDWARE;
+    ses->st_eth.Init.MediaInterface = ETH_MEDIA_INTERFACE_RMII;
+
+    return ERR_OK;
+}
+
+int
+stm32f4_eth_open(void)
+{
+    struct stm32f4_eth_state *ses = &stm32f4_eth_state;
+    struct netif *nif;
+    struct ip4_addr addr;
+
+    if (ses->cfg == NULL) {
+        return -1;
+    }
+
+    /*
+     * Register network interface with LwIP.
+     */
+    memset(&addr, 0, sizeof(addr));
+    nif = netif_add(&ses->nif, &addr, &addr, &addr, NULL, stm32f4_lwip_init,
+      ethernet_input);
+    assert(nif);
+    return 0;
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c81b7fe8/hw/hal/include/hal/hal_bsp.h
----------------------------------------------------------------------
diff --git a/hw/hal/include/hal/hal_bsp.h b/hw/hal/include/hal/hal_bsp.h
index 11f833b..10abc36 100644
--- a/hw/hal/include/hal/hal_bsp.h
+++ b/hw/hal/include/hal/hal_bsp.h
@@ -60,8 +60,6 @@ const struct hal_bsp_mem_dump *hal_bsp_core_dump(int *area_cnt);
 #define HAL_BSP_MAX_ID_LEN  32
 int hal_bsp_hw_id(uint8_t *id, int max_len);
 
-uint16_t bsp_get_refmv(void *cfgdata);
-
 #define HAL_BSP_POWER_ON (1)
 #define HAL_BSP_POWER_WFI (2)
 #define HAL_BSP_POWER_SLEEP (3)