mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-01 14:34:31 +00:00
refactor(i2c): rename some LL functions according to TRM descriptions
This commit is contained in:
@@ -269,7 +269,7 @@ static inline void i2c_ll_get_intr_mask(i2c_dev_t *hw, uint32_t *intr_status)
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
static inline void i2c_ll_slave_set_fifo_mode(i2c_dev_t *hw, bool fifo_mode_en)
|
||||
static inline void i2c_ll_enable_fifo_mode(i2c_dev_t *hw, bool fifo_mode_en)
|
||||
{
|
||||
hw->fifo_conf.nonfifo_en = fifo_mode_en ? 0 : 1;
|
||||
}
|
||||
@@ -289,7 +289,7 @@ static inline void i2c_ll_set_tout(i2c_dev_t *hw, int tout)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure I2C slave broadcasting mode.
|
||||
* @brief Enable the I2C slave to respond to broadcast address
|
||||
*
|
||||
* @param hw Beginning address of the peripheral registers
|
||||
* @param broadcast_en Set true to enable broadcast, else, set it false
|
||||
@@ -379,7 +379,7 @@ static inline void i2c_ll_master_write_cmd_reg(i2c_dev_t *hw, i2c_ll_hw_cmd_t cm
|
||||
static inline void i2c_ll_master_set_start_timing(i2c_dev_t *hw, int start_setup, int start_hold)
|
||||
{
|
||||
hw->scl_rstart_setup.time = start_setup;
|
||||
hw->scl_start_hold.time = start_hold-1;
|
||||
hw->scl_start_hold.time = start_hold - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -422,6 +422,7 @@ static inline void i2c_ll_set_sda_timing(i2c_dev_t *hw, int sda_sample, int sda_
|
||||
*/
|
||||
static inline void i2c_ll_set_txfifo_empty_thr(i2c_dev_t *hw, uint8_t empty_thr)
|
||||
{
|
||||
hw->fifo_conf.fifo_prt_en = 1;
|
||||
hw->fifo_conf.tx_fifo_wm_thrhd = empty_thr;
|
||||
}
|
||||
|
||||
@@ -436,6 +437,7 @@ static inline void i2c_ll_set_txfifo_empty_thr(i2c_dev_t *hw, uint8_t empty_thr)
|
||||
static inline void i2c_ll_set_rxfifo_full_thr(i2c_dev_t *hw, uint8_t full_thr)
|
||||
{
|
||||
hw->fifo_conf.fifo_prt_en = 1;
|
||||
hw->ctr.rx_full_ack_level = 0;
|
||||
hw->fifo_conf.rx_fifo_wm_thrhd = full_thr;
|
||||
}
|
||||
|
||||
@@ -552,7 +554,7 @@ static inline void i2c_ll_get_tout(i2c_dev_t *hw, int *timeout)
|
||||
* @return None
|
||||
*/
|
||||
__attribute__((always_inline))
|
||||
static inline void i2c_ll_master_trans_start(i2c_dev_t *hw)
|
||||
static inline void i2c_ll_start_trans(i2c_dev_t *hw)
|
||||
{
|
||||
hw->ctr.trans_start = 1;
|
||||
}
|
||||
@@ -569,7 +571,7 @@ static inline void i2c_ll_master_trans_start(i2c_dev_t *hw)
|
||||
static inline void i2c_ll_get_start_timing(i2c_dev_t *hw, int *setup_time, int *hold_time)
|
||||
{
|
||||
*setup_time = hw->scl_rstart_setup.time;
|
||||
*hold_time = hw->scl_start_hold.time+1;
|
||||
*hold_time = hw->scl_start_hold.time + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -600,7 +602,7 @@ __attribute__((always_inline))
|
||||
static inline void i2c_ll_write_txfifo(i2c_dev_t *hw, const uint8_t *ptr, uint8_t len)
|
||||
{
|
||||
uint32_t fifo_addr = (hw == &I2C0) ? 0x6001301c : 0x6002701c;
|
||||
for(int i = 0; i < len; i++) {
|
||||
for (int i = 0; i < len; i++) {
|
||||
WRITE_PERI_REG(fifo_addr, ptr[i]);
|
||||
}
|
||||
}
|
||||
@@ -618,7 +620,7 @@ __attribute__((always_inline))
|
||||
static inline void i2c_ll_read_rxfifo(i2c_dev_t *hw, uint8_t *ptr, uint8_t len)
|
||||
{
|
||||
uint32_t fifo_addr = (hw == &I2C0) ? 0x6001301c : 0x6002701c;
|
||||
for(int i = 0; i < len; i++) {
|
||||
for (int i = 0; i < len; i++) {
|
||||
ptr[i] = READ_PERI_REG(fifo_addr);
|
||||
}
|
||||
}
|
||||
@@ -634,7 +636,7 @@ static inline void i2c_ll_read_rxfifo(i2c_dev_t *hw, uint8_t *ptr, uint8_t len)
|
||||
*/
|
||||
static inline void i2c_ll_master_set_filter(i2c_dev_t *hw, uint8_t filter_num)
|
||||
{
|
||||
if(filter_num > 0) {
|
||||
if (filter_num > 0) {
|
||||
hw->scl_filter_cfg.thres = filter_num;
|
||||
hw->sda_filter_cfg.thres = filter_num;
|
||||
hw->scl_filter_cfg.en = 1;
|
||||
@@ -774,8 +776,6 @@ static inline void i2c_ll_slave_init(i2c_dev_t *hw)
|
||||
ctrl_reg.sda_force_out = 1;
|
||||
ctrl_reg.scl_force_out = 1;
|
||||
hw->ctr.val = ctrl_reg.val;
|
||||
hw->fifo_conf.fifo_addr_cfg_en = 0;
|
||||
hw->scl_stretch_conf.slave_scl_stretch_en = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -837,12 +837,12 @@ static inline void i2c_ll_reset_register(int i2c_port)
|
||||
#define i2c_ll_reset_register(...) do {(void)__DECLARE_RCC_ATOMIC_ENV; i2c_ll_reset_register(__VA_ARGS__);} while(0)
|
||||
|
||||
/**
|
||||
* @brief Set whether slave should auto start, or only start with start signal from master
|
||||
* @brief Enable I2C slave to automatically send data when addressed by the master
|
||||
*
|
||||
* @param hw Beginning address of the peripheral registers
|
||||
* @param slv_ex_auto_en 1 if slave auto start data transaction, otherwise, 0.
|
||||
*/
|
||||
static inline void i2c_ll_slave_tx_auto_start_en(i2c_dev_t *hw, bool slv_ex_auto_en)
|
||||
static inline void i2c_ll_slave_enable_auto_start(i2c_dev_t *hw, bool slv_ex_auto_en)
|
||||
{
|
||||
;// ESP32-S2 do not support
|
||||
}
|
||||
@@ -1157,8 +1157,8 @@ static inline void i2c_ll_slave_disable_rx_it(i2c_dev_t *hw)
|
||||
*/
|
||||
static inline void i2c_ll_set_scl_timing(i2c_dev_t *hw, int hight_period, int low_period)
|
||||
{
|
||||
hw->scl_low_period.period = low_period-1;
|
||||
hw->scl_high_period.period = hight_period/2+2;
|
||||
hw->scl_low_period.period = low_period - 1;
|
||||
hw->scl_high_period.period = hight_period / 2 + 2;
|
||||
hw->scl_high_period.scl_wait_high_period = hight_period - hw->scl_high_period.period;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user