You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2019/04/15 06:57:45 UTC
[GitHub] [mynewt-core] rymanluk commented on a change in pull request #1765:
hw/mcu/dialog: Move common code in I2C to helper
rymanluk commented on a change in pull request #1765: hw/mcu/dialog: Move common code in I2C to helper
URL: https://github.com/apache/mynewt-core/pull/1765#discussion_r275226229
##########
File path: hw/mcu/dialog/da1469x/src/hal_i2c.c
##########
@@ -210,40 +217,14 @@ hal_i2c_init(uint8_t i2c_num, void *usercfg)
return HAL_I2C_ERR_INVAL;
}
- /* Configure SCL, SDA.*/
- mcu_gpio_set_pin_function(da1469x_cfg->pin_scl, MCU_GPIO_MODE_OUTPUT, i2c->scl_func);
- mcu_gpio_set_pin_function(da1469x_cfg->pin_sda, MCU_GPIO_MODE_OUTPUT, i2c->sda_func);
-
- if (i2c_num == 0) {
- CRG_COM->RESET_CLK_COM_REG = CRG_COM_RESET_CLK_COM_REG_I2C_CLK_SEL_Msk;
- CRG_COM->SET_CLK_COM_REG = CRG_COM_RESET_CLK_COM_REG_I2C_ENABLE_Msk;
- } else {
- CRG_COM->RESET_CLK_COM_REG = CRG_COM_RESET_CLK_COM_REG_I2C2_CLK_SEL_Msk;
- CRG_COM->SET_CLK_COM_REG = CRG_COM_RESET_CLK_COM_REG_I2C2_ENABLE_Msk;
- }
-
- /* Abort ongoing transactions and disable */
- i2c->regs->I2C_ENABLE_REG |= (1 << I2C_I2C_ENABLE_REG_I2C_ABORT_Pos);
- i2c->regs->I2C_ENABLE_REG &= ~(1 << I2C_I2C_ENABLE_REG_I2C_EN_Pos);
- while (i2c->regs->I2C_ENABLE_STATUS_REG & I2C_I2C_ENABLE_STATUS_REG_IC_EN_Msk);
- /* TODO Maybe should wait here some time */
-
- /* Configure I2C_CON_REG, first configure to master */
- i2c->regs->I2C_CON_REG = (1 << I2C_I2C_CON_REG_I2C_MASTER_MODE_Pos);
-
- /* Use 7-bit addressing */
- i2c->regs->I2C_CON_REG &= ~(1 << I2C_I2C_CON_REG_I2C_10BITADDR_MASTER_Pos);
+ i2c_init_hw(i2c, da1469x_cfg->pin_scl, da1469x_cfg->pin_sda);
cfg.frequency = da1469x_cfg->frequency;
rc = i2c_config(i2c, &cfg);
if (rc) {
return rc;
}
- i2c->regs->I2C_INTR_MASK_REG = 0x0000;
-
- NVIC_EnableIRQ(i2c->irqn);
Review comment:
looks like now interrupt is enabled inside `i2c_init_hw()` before `i2c_config()` is called and this does not seems to be right. On the other side we support only MASTER role so it should be acceptable.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services