ESP32-P4 OBC Firmware
ESP-IDF firmware for Plant-B CubeSat OBC
 
Loading...
Searching...
No Matches
I²C Master Bus

Typedefs

typedef float i2c_freq_t
 Type for I²C clock frequency in Hz.
 
typedef uint8_t i2c_sda_t
 Type for I²C SDA pin number.
 
typedef uint8_t i2c_scl_t
 Type for I²C SCL pin number.
 

Functions

i2c_bus_handle_t i2c_master_bus_init (i2c_port_t p, i2c_sda_t d, i2c_scl_t c, i2c_freq_t f)
 Initialize an I²C master bus.
 
esp_err_t i2c_master_bus_scan (i2c_bus_handle_t bus)
 Scan for devices on the given I²C bus.
 
void i2c_master_bus_deinit (i2c_bus_handle_t bus)
 Deinitialize the I²C master bus.
 

I²C Master Default Pins and Settings

#define I2C_MASTER_SCL_IO   (8)
 GPIO number for I²C SCL.
 
#define I2C_MASTER_SDA_IO   (7)
 GPIO number for I²C SDA.
 
#define I2C_MASTER_NUM   I2C_NUM_0
 I²C port number.
 
#define I2C_MASTER_FREQ_HZ   (100000)
 I²C clock frequency in Hz.
 

Detailed Description

ESP-IDF wrapper for default I²C master bus management.

Uses the new ESP-IDF I²C interface.

Macro Definition Documentation

◆ I2C_MASTER_FREQ_HZ

#define I2C_MASTER_FREQ_HZ   (100000)

I²C clock frequency in Hz.

◆ I2C_MASTER_NUM

#define I2C_MASTER_NUM   I2C_NUM_0

I²C port number.

◆ I2C_MASTER_SCL_IO

#define I2C_MASTER_SCL_IO   (8)

GPIO number for I²C SCL.

◆ I2C_MASTER_SDA_IO

#define I2C_MASTER_SDA_IO   (7)

GPIO number for I²C SDA.

Typedef Documentation

◆ i2c_freq_t

typedef float i2c_freq_t

Type for I²C clock frequency in Hz.

◆ i2c_scl_t

typedef uint8_t i2c_scl_t

Type for I²C SCL pin number.

◆ i2c_sda_t

typedef uint8_t i2c_sda_t

Type for I²C SDA pin number.

Function Documentation

◆ i2c_master_bus_deinit()

void i2c_master_bus_deinit ( i2c_bus_handle_t bus)

Deinitialize the I²C master bus.

Releases resources and frees memory associated with the bus handle.

Parameters
[in,out]busHandle to the I²C bus to deinitialize.
Warning
This function must run inside a critical section.

◆ i2c_master_bus_init()

i2c_bus_handle_t i2c_master_bus_init ( i2c_port_t p,
i2c_sda_t d,
i2c_scl_t c,
i2c_freq_t f )

Initialize an I²C master bus.

Configures the I²C controller with the given pins, port, and clock frequency.

Parameters
[in]pI²C port number.
[in]dSDA pin number.
[in]cSCL pin number.
[in]fClock frequency.
Return values
i2c_bus_handle_tHandle to the initialized I²C bus.
NULLOn failure.
Note
Must call i2c_master_bus_deinit() to free resources later.
Warning
This function must run inside a critical section.

◆ i2c_master_bus_scan()

esp_err_t i2c_master_bus_scan ( i2c_bus_handle_t bus)

Scan for devices on the given I²C bus.

Logs detected device addresses.

Parameters
[in]busHandle to the I²C bus.
Return values
ESP_OKOn success.
ESP_ERR_INVALID_ARGIf any parameter is NULL.