You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2022/04/08 13:01:56 UTC

[mynewt-core] branch master updated: da1469x/i2c: Enable I2C controller on init

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

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


The following commit(s) were added to refs/heads/master by this push:
     new ab4f17cf0 da1469x/i2c: Enable I2C controller on init
ab4f17cf0 is described below

commit ab4f17cf0041bd6f81b15225fbee96c0b88022a4
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Fri Jun 25 15:41:41 2021 +0200

    da1469x/i2c: Enable I2C controller on init
    
    hal_i2c_init function used to configure I2C hardware completely.
    Power improvements changed this behavior, but those changes
    were mostly for bus driver functionality where power management
    is handled batter.
    
    This brings back enabling hardware in hal_i2c_init in case
    some application (sensors_test) uses I2C with hal functions
    only and does not care about power management.
---
 hw/mcu/dialog/da1469x/src/hal_i2c.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/hw/mcu/dialog/da1469x/src/hal_i2c.c b/hw/mcu/dialog/da1469x/src/hal_i2c.c
index 7ccccce5f..1d6450617 100644
--- a/hw/mcu/dialog/da1469x/src/hal_i2c.c
+++ b/hw/mcu/dialog/da1469x/src/hal_i2c.c
@@ -236,6 +236,7 @@ hal_i2c_init(uint8_t i2c_num, void *usercfg)
 {
     const struct da1469x_hal_i2c_cfg *da1469x_cfg = usercfg;
     const struct da1469x_hal_i2c *i2c;
+    int rc;
 
     i2c = hal_i2c_resolve(i2c_num);
     if (!i2c) {
@@ -248,7 +249,12 @@ hal_i2c_init(uint8_t i2c_num, void *usercfg)
 
     i2c_init_hw(i2c, da1469x_cfg->pin_scl, da1469x_cfg->pin_sda);
 
-    return i2c_config(i2c, da1469x_cfg->frequency);
+    rc = i2c_config(i2c, da1469x_cfg->frequency);
+    if (rc == 0) {
+        rc = hal_i2c_enable(i2c_num);
+    }
+
+    return rc;
 }
 
 static uint32_t