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

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

commit 6ccc2f224f439622188cf14d4b01598b72f6d1f9
Author: Will San Filippo <william.sanfili...@juul.com>
AuthorDate: Thu May 16 13:22:43 2024 -0400

    hw/mcu/dialog: Add 1MHz i2c speed
    
    Adds 1MHz i2c speed to the i2c hal. The 1MHz speed requires
    high speed mode on the chip. In order for this to work it appears
    that the RESTART_EN bit has to be set in the control register or
    a tx abort condition occurs (bit 8 in tx abort source reg).
---
 hw/mcu/dialog/da1469x/src/hal_i2c.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/hw/mcu/dialog/da1469x/src/hal_i2c.c 
b/hw/mcu/dialog/da1469x/src/hal_i2c.c
index d6983b9c6..30147e9ca 100644
--- a/hw/mcu/dialog/da1469x/src/hal_i2c.c
+++ b/hw/mcu/dialog/da1469x/src/hal_i2c.c
@@ -186,8 +186,9 @@ i2c_config(const struct da1469x_hal_i2c *i2c, uint32_t 
frequency)
     /* Configure I2C_CON_REG */
     i2c_con_reg = i2c->data->I2C_CON_REG;
 
-    /* Clear speed register */
-    i2c_con_reg &= ~I2C_I2C_CON_REG_I2C_SPEED_Msk;
+    /* Clear speed and restart enable bits */
+    i2c_con_reg &= ~(I2C_I2C_CON_REG_I2C_SPEED_Msk |
+                     I2C_I2C_CON_REG_I2C_RESTART_EN_Msk);
     switch (frequency) {
     case 100:
         i2c_con_reg |= (1 << I2C_I2C_CON_REG_I2C_SPEED_Pos);
@@ -195,6 +196,10 @@ i2c_config(const struct da1469x_hal_i2c *i2c, uint32_t 
frequency)
     case 400:
         i2c_con_reg |= (2 << I2C_I2C_CON_REG_I2C_SPEED_Pos);
         break;
+    case 1000:
+        i2c_con_reg |= ((3 << I2C_I2C_CON_REG_I2C_SPEED_Pos) |
+                        I2C_I2C_CON_REG_I2C_RESTART_EN_Msk);
+        break;
     default:
         return HAL_I2C_ERR_INVAL;
     }

Reply via email to