Function esp_idf_hal::sys::i2c_cmd_link_create_static
source · pub unsafe extern "C" fn i2c_cmd_link_create_static(
buffer: *mut u8,
size: u32,
) -> *mut c_void
Expand description
@brief Create and initialize an I2C commands list with a given buffer.
All the allocations for data or signals (START, STOP, ACK, …) will be
performed within this buffer.
This buffer must be valid during the whole transaction.
After finishing the I2C transactions, it is required to call i2c_cmd_link_delete_static()
.
@note It is highly advised to not allocate this buffer on the stack. The size of the data
used underneath may increase in the future, resulting in a possible stack overflow as the macro
I2C_LINK_RECOMMENDED_SIZE
would also return a bigger value.
A better option is to use a buffer allocated statically or dynamically (with malloc
).
@param buffer Buffer to use for commands allocations @param size Size in bytes of the buffer
@return Handle to the I2C command link or NULL if the buffer provided is too small, please
use I2C_LINK_RECOMMENDED_SIZE
macro to get the recommended size for the buffer.