![]() ![]() This function is a wrapper to i2c_master_start(), i2c_master_write(), i2c_master_read(), etc… It shall only be called in I2C master mode. Perform a read to a device connected to a particular I2C port. Ticks_to_wait: Maximum ticks to wait before issuing a timeout.Įsp_err_t i2c_master_read_from_device ( i2c_port_t i2c_num, uint8_t device_address, uint8_t * read_buffer, size_t read_size, TickType_t ticks_to_wait ) ¶ Write_size: Size, in bytes, of the write buffer I2c_num: I2C port number to perform the transfer onĭevice_address: I2C device’s 7-bit address This function is a wrapper to i2c_master_start(), i2c_master_write(), i2c_master_read(), etc… It shall only be called in I2C master mode.ĮSP_FAIL Sending command error, slave hasn’t ACK the transfer.ĮSP_ERR_INVALID_STATE I2C driver not installed or not in master mode.ĮSP_ERR_TIMEOUT Operation timeout because the bus is busy. Perform a write to a device connected to a particular I2C port. Scl_pullup_en: Enable the internal pullup for SCL pinĮsp_err_t i2c_master_write_to_device ( i2c_port_t i2c_num, uint8_t device_address, const uint8_t * write_buffer, size_t write_size, TickType_t ticks_to_wait ) ¶ Sda_pullup_en: Enable the internal pullup for SDA pin Scl_io_num: GPIO number for I2C SCL signal Sda_io_num: GPIO number for I2C SDA signal Handle: Handle return from esp_intr_alloc.Įsp_err_t i2c_isr_free ( intr_handle_t handle ) ¶Įsp_err_t i2c_set_pin ( i2c_port_t i2c_num, int sda_io_num, int scl_io_num, bool sda_pullup_en, bool scl_pullup_en, i2c_mode_t mode ) ¶Ĭonfigure GPIO pins for I2C SCK and SDA signals. ![]() I2c_num: I2C port number to attach handler to I2c_conf: Pointer to the I2C configurationĮsp_err_t i2c_reset_tx_fifo ( i2c_port_t i2c_num ) ¶Įsp_err_t i2c_reset_rx_fifo ( i2c_port_t i2c_num ) ¶Įsp_err_t i2c_isr_register ( i2c_port_t i2c_num, void (* fn) (void * ), void * arg, int intr_alloc_flags, intr_handle_t * handle, ) ¶ ReturnĮsp_err_t i2c_param_config ( i2c_port_t i2c_num, const i2c_config_t * i2c_conf ) ¶Ĭonfigure an I2C bus with the given configuration. Please make sure that no thread will continuously hold semaphores before calling the delete function. This function does not guarantee thread safety. See esp_intr_alloc.h for more info.Įsp_err_t i2c_driver_delete ( i2c_port_t i2c_num ) ¶ One or multiple (ORred) ESP_INTR_FLAG_* values. Intr_alloc_flags: Flags used to allocate the interrupt. Only slave mode will use this value, it is ignored in master mode. In this case, please use the memory allocated from internal RAM in i2c read and write function, because we can not access the psram(if psram is enabled) in interrupt handle function when cache is disabled. In master mode, if the cache is likely to be disabled(such as write flash) and the slave is time-sensitive, ESP_INTR_FLAG_IRAM is suggested to be used. If you want to modify already entered values, use the function i2c_param_config().įunctions ¶ esp_err_t i2c_driver_install ( i2c_port_t i2c_num, i2c_mode_t mode, size_t slv_rx_buf_len, size_t slv_tx_buf_len, int intr_alloc_flags ) ¶ You can also select different pins for SDA and SCL signals and alter the configuration of pull-ups with the function i2c_set_pin(). To check the default parameter values which are set during the driver configuration process, please refer to the file driver/i2c.c and look for defines with the suffix _DEFAULT. ![]() For example, to check the I2C timeout value, call i2c_get_timeout(). Timing relationship between SCL and SDA signals when slave samples, as well as when master togglesĬhoice between transmitting / receiving the LSB or MSB first, choose one of the modes defined in i2c_trans_mode_tĮach of the above functions has a _get_ counterpart to check the currently set value. SCL and SDA signal timing used during generation of stop signals SCL and SDA signal timing used during generation of start signals Other Configurable I2C Communication Parameters ¶ The frequency of APB is specified in I2C_APB_CLK_FREQ. Please note that the timing values are defined in APB clock cycles. Some other related parameters are pre-configured in registers of the I2C controller.Īll these parameters can be changed to user-defined values by calling dedicated functions given in the table below. As mentioned at the end of Section Configuration, when the function i2c_param_config() initializes the driver configuration for an I2C port, it also sets several I2C communication parameters to default values defined in the I2C specification. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |