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