You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ut...@apache.org on 2018/04/18 21:56:32 UTC

[mynewt-core] 09/13: Add stm32f3discovery i2c config

This is an automated email from the ASF dual-hosted git repository.

utzig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 0f84660414f8497da48a96d0bc277a48c9087ccf
Author: Fabio Utzig <ut...@apache.org>
AuthorDate: Thu Mar 22 14:54:08 2018 -0300

    Add stm32f3discovery i2c config
---
 hw/bsp/stm32f3discovery/src/hal_bsp.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/hw/bsp/stm32f3discovery/src/hal_bsp.c b/hw/bsp/stm32f3discovery/src/hal_bsp.c
index 95a3e87..0d77cff 100644
--- a/hw/bsp/stm32f3discovery/src/hal_bsp.c
+++ b/hw/bsp/stm32f3discovery/src/hal_bsp.c
@@ -32,6 +32,7 @@
 #include <hal/hal_bsp.h>
 #include <hal/hal_flash_int.h>
 #include <hal/hal_gpio.h>
+#include <hal/hal_i2c.h>
 #include <hal/hal_system.h>
 
 #if MYNEWT_VAL(SPI_0_MASTER) || MYNEWT_VAL(SPI_0_SLAVE) || \
@@ -46,6 +47,8 @@
 #include "mcu/stm32_hal.h"
 
 #include "bsp/bsp.h"
+#include "mcu/mcu.h"
+#include "os/os_cputime.h"
 
 #if MYNEWT_VAL(UART_0)
 static struct uart_dev hal_uart[1];
@@ -92,6 +95,19 @@ struct stm32_hal_spi_cfg spi1_cfg = {
 };
 #endif
 
+#if MYNEWT_VAL(I2C_0)
+static struct stm32_hal_i2c_cfg i2c_cfg0 = {
+    .hic_i2c = I2C1,
+    .hic_rcc_reg = &RCC->APB1ENR,
+    .hic_rcc_dev = RCC_APB1ENR_I2C1EN,
+    .hic_pin_sda = MCU_GPIO_PORTB(9),
+    .hic_pin_scl = MCU_GPIO_PORTB(8),
+    .hic_pin_af = GPIO_AF4_I2C1,
+    .hic_10bit = 0,
+    .hic_speed = 100000,
+};
+#endif
+
 static const struct hal_bsp_mem_dump dump_cfg[] = {
     [0] = {
         .hbmd_start = &_sram_start,
@@ -153,6 +169,11 @@ hal_bsp_init(void)
     assert(rc == 0);
 #endif
 
+#if MYNEWT_VAL(I2C_0)
+    rc = hal_i2c_init(0, &i2c_cfg0);
+    assert(rc == 0);
+#endif
+
 #if MYNEWT_VAL(TIMER_0)
     rc = hal_timer_init(0, TIM15);
     assert(rc == 0);

-- 
To stop receiving notification emails like this one, please contact
utzig@apache.org.