11/*
2- * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
2+ * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
33 *
44 * SPDX-License-Identifier: Apache-2.0
55 */
@@ -821,6 +821,20 @@ static inline bool i2c_ll_master_is_bus_clear_done(i2c_dev_t *hw)
821821 return hw -> scl_sp_conf .scl_rst_slv_en ;
822822}
823823
824+ /**
825+ * @brief Set the ACK level that the I2C master must send when the Rx FIFO count has reached the threshold value.
826+ * ack_level: 1 (NACK)
827+ * ack_level: 0 (ACK)
828+ *
829+ * @param hw Beginning address of the peripheral registers
830+ *
831+ * @return None
832+ */
833+ static inline void i2c_ll_master_rx_full_ack_level (i2c_dev_t * hw , int ack_level )
834+ {
835+ hw -> ctr .rx_full_ack_level = ack_level ;
836+ }
837+
824838/**
825839 * @brief Set I2C source clock
826840 *
@@ -847,37 +861,37 @@ static inline void i2c_ll_enable_controller_clock(i2c_dev_t *hw, bool en)
847861}
848862
849863/**
850- * @brief Init I2C master
864+ * @brief Set the I2C bus mode (Master or Slave)
851865 *
852- * @param hw Beginning address of the peripheral registers
853- *
854- * @return None
866+ * @param hw Pointer to the I2C hardware register structure.
867+ * @param mode The desired I2C bus mode (Master or Slave).
855868 */
856- static inline void i2c_ll_master_init (i2c_dev_t * hw )
869+ static inline void i2c_ll_set_mode (i2c_dev_t * hw , i2c_bus_mode_t mode )
857870{
858- typeof (hw -> ctr ) ctrl_reg ;
859- ctrl_reg .val = 0 ;
860- ctrl_reg .ms_mode = 1 ;
861- ctrl_reg .clk_en = 1 ;
862- ctrl_reg .sda_force_out = 1 ;
863- ctrl_reg .scl_force_out = 1 ;
864- hw -> ctr .val = ctrl_reg .val ;
871+ hw -> ctr .ms_mode = (mode == I2C_BUS_MODE_MASTER ) ? 1 : 0 ;
865872}
866873
867874/**
868- * @brief Init I2C slave
875+ * @brief Enable or disable open-drain mode for I2C pins
869876 *
870- * @param hw Beginning address of the peripheral registers
877+ * @param hw Pointer to the I2C hardware register structure.
878+ * @param enable_od Boolean flag to enable or disable open-drain mode:
879+ */
880+ static inline void i2c_ll_enable_pins_open_drain (i2c_dev_t * hw , bool enable_od )
881+ {
882+ hw -> ctr .sda_force_out = enable_od ;
883+ hw -> ctr .scl_force_out = enable_od ;
884+ }
885+
886+ /**
887+ * @brief Enable or disable arbitration for I2C communication.
871888 *
872- * @return None
889+ * @param hw Pointer to the I2C hardware instance.
890+ * @param enable_arbi Boolean flag to enable (true) or disable (false) arbitration.
873891 */
874- static inline void i2c_ll_slave_init (i2c_dev_t * hw )
892+ static inline void i2c_ll_enable_arbitration (i2c_dev_t * hw , bool enable_arbi )
875893{
876- typeof (hw -> ctr ) ctrl_reg ;
877- ctrl_reg .val = 0 ;
878- ctrl_reg .sda_force_out = 1 ;
879- ctrl_reg .scl_force_out = 1 ;
880- hw -> ctr .val = ctrl_reg .val ;
894+ hw -> ctr .arbitration_en = enable_arbi ;
881895}
882896
883897/**
0 commit comments