#include <stdio.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
#include "driver/i2c_master.h"
Go to the source code of this file.
|
uint8_t | i2c_open (i2c_master_bus_handle_t *bus_handle, i2c_master_dev_handle_t *dev_handle, const uint8_t address) |
| initializes the i2c communications and points the handles to correctly initialized variables on the heap.
|
◆ I2C_DEVICE_ADDRESS_LEN
#define I2C_DEVICE_ADDRESS_LEN I2C_ADDR_BIT_LEN_7 |
◆ I2C_MASTER_FREQ_HZ
#define I2C_MASTER_FREQ_HZ 100000 |
I2C master clock frequency
Definition at line 18 of file lcd_i2c.h.
◆ I2C_MASTER_NUM
#define I2C_MASTER_NUM I2C_NUM_0 |
I2C port number for master dev
Definition at line 17 of file lcd_i2c.h.
◆ I2C_MASTER_RX_BUF_DISABLE
#define I2C_MASTER_RX_BUF_DISABLE 0 |
I2C master doesn't need buffer
Definition at line 20 of file lcd_i2c.h.
◆ I2C_MASTER_SCL_IO
#define I2C_MASTER_SCL_IO GPIO_NUM_2 |
GPIO number used for I2C master clock
Definition at line 15 of file lcd_i2c.h.
◆ I2C_MASTER_SDA_IO
#define I2C_MASTER_SDA_IO GPIO_NUM_3 |
GPIO number used for I2C master data
Definition at line 16 of file lcd_i2c.h.
◆ I2C_MASTER_TIMEOUT_MS
#define I2C_MASTER_TIMEOUT_MS 1000 |
◆ I2C_MASTER_TX_BUF_DISABLE
#define I2C_MASTER_TX_BUF_DISABLE 0 |
I2C master doesn't need buffer
Definition at line 19 of file lcd_i2c.h.
◆ i2c_open()
uint8_t i2c_open |
( |
i2c_master_bus_handle_t * | bus_handle, |
|
|
i2c_master_dev_handle_t * | dev_handle, |
|
|
const uint8_t | address ) |
initializes the i2c communications and points the handles to correctly initialized variables on the heap.
- Parameters
-
[out] | bus_handle | handle for initializing the bus |
[out] | dev_handle | handle for initializing the device on bus |
[in] | address | device address on bus to communicate with |
Definition at line 3 of file lcd_i2c.c.
3 {
4 i2c_master_bus_config_t bus_config = {
8 .clk_source = I2C_CLK_SRC_DEFAULT,
9 .glitch_ignore_cnt = 7,
10 .flags.enable_internal_pullup = true,
11 };
12 ESP_ERROR_CHECK(i2c_new_master_bus(&bus_config, bus_handle));
13
14 i2c_device_config_t dev_config = {
16 .device_address = address,
18 };
19 ESP_ERROR_CHECK(i2c_master_bus_add_device(*bus_handle, &dev_config, dev_handle));
20
21 return 0;
22}
#define I2C_MASTER_SCL_IO
#define I2C_MASTER_FREQ_HZ
#define I2C_DEVICE_ADDRESS_LEN
#define I2C_MASTER_SDA_IO