You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge branch 'fix/i2c_scl_freq_s2_v5.4' into 'release/v5.4'
fix(i2c): Fix scl frequency is wrong on esp32s2 in legacy i2c driver & Add api for customize i2c transaction interface for un-standard i2c device (backport v5.4)
See merge request espressif/esp-idf!37113
Copy file name to clipboardExpand all lines: components/esp_driver_i2c/include/driver/i2c_master.h
+60-2Lines changed: 60 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
/*
2
-
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
2
+
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
3
3
*
4
4
* SPDX-License-Identifier: Apache-2.0
5
5
*/
@@ -39,19 +39,53 @@ typedef struct {
39
39
} flags; /*!< I2C master config flags */
40
40
} i2c_master_bus_config_t;
41
41
42
+
#defineI2C_DEVICE_ADDRESS_NOT_USED (0xffff) /*!< Skip carry address bit in driver transmit and receive */
43
+
42
44
/**
43
45
* @brief I2C device configuration
44
46
*/
45
47
typedefstruct {
46
48
i2c_addr_bit_len_tdev_addr_length; /*!< Select the address length of the slave device. */
47
-
uint16_tdevice_address; /*!< I2C device raw address. (The 7/10 bit address without read/write bit) */
49
+
uint16_tdevice_address; /*!< I2C device raw address. (The 7/10 bit address without read/write bit). Macro I2C_DEVICE_ADDRESS_NOT_USED (0xFFFF) stands for skip the address config inside driver. */
48
50
uint32_tscl_speed_hz; /*!< I2C SCL line frequency. */
49
51
uint32_tscl_wait_us; /*!< Timeout value. (unit: us). Please note this value should not be so small that it can handle stretch/disturbance properly. If 0 is set, that means use the default reg value*/
50
52
struct {
51
53
uint32_tdisable_ack_check: 1; /*!< Disable ACK check. If this is set false, that means ack check is enabled, the transaction will be stopped and API returns error when nack is detected. */
52
54
} flags; /*!< I2C device config flags */
53
55
} i2c_device_config_t;
54
56
57
+
/**
58
+
* @brief Structure representing an I2C operation job
59
+
*
60
+
* This structure is used to define individual I2C operations (write or read)
61
+
* within a sequence of I2C master transactions.
62
+
*/
63
+
typedefstruct {
64
+
i2c_master_command_tcommand; /**< I2C command indicating the type of operation (START, WRITE, READ, or STOP) */
65
+
union {
66
+
/**
67
+
* @brief Structure for WRITE command
68
+
*
69
+
* Used when the `command` is set to `I2C_MASTER_CMD_WRITE`.
70
+
*/
71
+
struct {
72
+
boolack_check; /**< Whether to enable ACK check during WRITE operation */
73
+
uint8_t*data; /**< Pointer to the data to be written */
74
+
size_ttotal_bytes; /**< Total number of bytes to write */
75
+
} write;
76
+
/**
77
+
* @brief Structure for READ command
78
+
*
79
+
* Used when the `command` is set to `I2C_MASTER_CMD_READ`.
80
+
*/
81
+
struct {
82
+
i2c_ack_value_tack_value; /**< ACK value to send after the read (ACK or NACK) */
83
+
uint8_t*data; /**< Pointer to the buffer for storing the data read from the bus */
84
+
size_ttotal_bytes; /**< Total number of bytes to read */
85
+
} read;
86
+
};
87
+
} i2c_operation_job_t;
88
+
55
89
/**
56
90
* @brief I2C master transmit buffer information structure
0 commit comments