LCD 1602 Driver with ESP32 I2C 1.1
This is a complete driver for LCD 1602 using I2C with the ESP32
Loading...
Searching...
No Matches
lcd_i2c.c File Reference
#include "lcd_i2c.h"

Go to the source code of this file.

Functions

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.

Function Documentation

◆ 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_handlehandle for initializing the bus
[out]dev_handlehandle for initializing the device on bus
[in]addressdevice address on bus to communicate with

Definition at line 3 of file lcd_i2c.c.

3 {
4 i2c_master_bus_config_t bus_config = {
5 .i2c_port = I2C_MASTER_NUM,
6 .sda_io_num = I2C_MASTER_SDA_IO,
7 .scl_io_num = I2C_MASTER_SCL_IO,
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 = {
15 .dev_addr_length = I2C_DEVICE_ADDRESS_LEN,
16 .device_address = address,
17 .scl_speed_hz = I2C_MASTER_FREQ_HZ,
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
Definition lcd_i2c.h:15
#define I2C_MASTER_FREQ_HZ
Definition lcd_i2c.h:18
#define I2C_MASTER_NUM
Definition lcd_i2c.h:17
#define I2C_DEVICE_ADDRESS_LEN
Definition lcd_i2c.h:22
#define I2C_MASTER_SDA_IO
Definition lcd_i2c.h:16