mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-02 06:38:47 +00:00
fix(i2c): Fix that fsm reset cause i2c scl frequency changed on esp32s2,
Closes https://github.com/espressif/esp-idf/issues/15724
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -821,6 +821,20 @@ static inline bool i2c_ll_master_is_bus_clear_done(i2c_dev_t *hw)
|
||||
return hw->scl_sp_conf.scl_rst_slv_en;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the ACK level that the I2C master must send when the Rx FIFO count has reached the threshold value.
|
||||
* ack_level: 1 (NACK)
|
||||
* ack_level: 0 (ACK)
|
||||
*
|
||||
* @param hw Beginning address of the peripheral registers
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
static inline void i2c_ll_master_rx_full_ack_level(i2c_dev_t *hw, int ack_level)
|
||||
{
|
||||
hw->ctr.rx_full_ack_level = ack_level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set I2C source clock
|
||||
*
|
||||
@@ -847,37 +861,37 @@ static inline void i2c_ll_enable_controller_clock(i2c_dev_t *hw, bool en)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Init I2C master
|
||||
* @brief Set the I2C bus mode (Master or Slave)
|
||||
*
|
||||
* @param hw Beginning address of the peripheral registers
|
||||
*
|
||||
* @return None
|
||||
* @param hw Pointer to the I2C hardware register structure.
|
||||
* @param mode The desired I2C bus mode (Master or Slave).
|
||||
*/
|
||||
static inline void i2c_ll_master_init(i2c_dev_t *hw)
|
||||
static inline void i2c_ll_set_mode(i2c_dev_t *hw, i2c_bus_mode_t mode)
|
||||
{
|
||||
typeof(hw->ctr) ctrl_reg;
|
||||
ctrl_reg.val = 0;
|
||||
ctrl_reg.ms_mode = 1;
|
||||
ctrl_reg.clk_en = 1;
|
||||
ctrl_reg.sda_force_out = 1;
|
||||
ctrl_reg.scl_force_out = 1;
|
||||
hw->ctr.val = ctrl_reg.val;
|
||||
hw->ctr.ms_mode = (mode == I2C_BUS_MODE_MASTER) ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Init I2C slave
|
||||
* @brief Enable or disable open-drain mode for I2C pins
|
||||
*
|
||||
* @param hw Beginning address of the peripheral registers
|
||||
*
|
||||
* @return None
|
||||
* @param hw Pointer to the I2C hardware register structure.
|
||||
* @param enable_od Boolean flag to enable or disable open-drain mode:
|
||||
*/
|
||||
static inline void i2c_ll_slave_init(i2c_dev_t *hw)
|
||||
static inline void i2c_ll_enable_pins_open_drain(i2c_dev_t *hw, bool enable_od)
|
||||
{
|
||||
typeof(hw->ctr) ctrl_reg;
|
||||
ctrl_reg.val = 0;
|
||||
ctrl_reg.sda_force_out = 1;
|
||||
ctrl_reg.scl_force_out = 1;
|
||||
hw->ctr.val = ctrl_reg.val;
|
||||
hw->ctr.sda_force_out = enable_od;
|
||||
hw->ctr.scl_force_out = enable_od;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable or disable arbitration for I2C communication.
|
||||
*
|
||||
* @param hw Pointer to the I2C hardware instance.
|
||||
* @param enable_arbi Boolean flag to enable (true) or disable (false) arbitration.
|
||||
*/
|
||||
static inline void i2c_ll_enable_arbitration(i2c_dev_t *hw, bool enable_arbi)
|
||||
{
|
||||
hw->ctr.arbitration_en = enable_arbi;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user