Core2 for AWS IoT EduKit BSP 1.5.1
Core2ForAWS_Port_A_I2C_Write
esp_err_t Core2ForAWS_Port_A_I2C_Write(I2CDevice_t device, uint32_t register_address, uint8_t *data, uint16_t length);
esp_err_t Core2ForAWS_Port_A_I2C_Write(I2CDevice_t device, uint32_t register_address, uint8_t *data, uint16_t length)
Writes to I2C peripheral connected to expansion port A.
Definition: core2forAWS.c:526
void * I2CDevice_t
A pointer to the I2C peripheral configuration.
Definition: i2c_device.h:41

Writes to I2C peripheral connected to expansion port A.

This function writes a specified number of bytes starting from the specified register on the peripheral.

Note
Some peripherals do not support specifying a register address to write to. In this scenario, input the I2C_NO_REG macro as the register_address.

Read more about I2C capabilities of the ESP32 microcontroller and available APIs in the ESP-IDF.

The example code allocates an I2C peripheral called port_A_peripheral of type I2CDevice_t that has a 7-bit device address of 0x68 and uses the standard baud rate. It then writes a single byte of data to a specific register on the device, with a message printed to the serial output if successful.

Example:

#include <stdio.h>
#include <stdlib.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include "esp_log.h"
#include "core2forAWS.h"
#define DEVICE_ADDRESS 0x68
static const char *TAG = "MAIN";
void app_main()
{
uint8_t my_data = 23;
esp_err_t err = Core2ForAWS_Port_A_I2C_Read(port_A_peripheral, 0x30, &my_data, 1);
if(!err){
ESP_LOGI(TAG, "Successfully wrote to the I2C peripheral");
}
}
I2CDevice_t Core2ForAWS_Port_A_I2C_Begin(uint8_t device_address, uint32_t baud)
Allocates a peripheral connected to expansion port A.
Definition: core2forAWS.c:518
void Core2ForAWS_Init(void)
Initializes the power chip with default values, enables battery charging, and initializes all enabled...
Definition: core2forAWS.c:32
esp_err_t Core2ForAWS_Port_A_I2C_Read(I2CDevice_t device, uint32_t register_address, uint8_t *data, uint16_t length)
Reads from I2C peripheral connected to expansion port A.
Definition: core2forAWS.c:522
Functions to initialize and access Core2 for AWS IoT EduKit hardware features.
#define PORT_A_I2C_STANDARD_BAUD
The standard baud rate for I2C peripherals connected to Port A.
Definition: core2forAWS.h:191
#define TAG
Definition: i2c_device.c:10
Parameters
[in]deviceThe device configuration pointer.
[in]register_addressThe address of the register to begin reading to.
[in]dataThe data to write to the register(s).
[in]lengthThe number of bytes to write to the peripheral.
Returns
The I2C device configuration.