* Add Config * Add Cache and remove pre-commit action * [pre-commit.ci lite] apply automatic fixes * Remove freeze * Fix * Update action * Use latest stable Python 3 version * Improve caching * Improve cache tag * Improve bot message * fix(typos): Fix typos * fix(typos): Fix more typos * refactor(udp_server): Convert script from Python 2 to 3 * Fix whitespace * Clang-format fixes * Prettier fixes * Black formatting * Manual fixes * Line endings * Fix flake and make Vale manual * Fix flake and reformat --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Co-authored-by: Rodrigo Garcia <rodrigo.garcia@espressif.com>
30 lines
722 B
C++
30 lines
722 B
C++
#include "Wire.h"
|
|
|
|
#define I2C_DEV_ADDR 0x55
|
|
|
|
uint32_t i = 0;
|
|
|
|
void setup() {
|
|
Serial.begin(115200);
|
|
Serial.setDebugOutput(true);
|
|
Wire.begin();
|
|
}
|
|
|
|
void loop() {
|
|
delay(5000);
|
|
|
|
//Write message to the slave
|
|
Wire.beginTransmission(I2C_DEV_ADDR);
|
|
Wire.printf("Hello World! %lu", i++);
|
|
uint8_t error = Wire.endTransmission(true);
|
|
Serial.printf("endTransmission: %u\n", error);
|
|
|
|
//Read 16 bytes from the slave
|
|
uint8_t bytesReceived = Wire.requestFrom(I2C_DEV_ADDR, 16);
|
|
Serial.printf("requestFrom: %u\n", bytesReceived);
|
|
if ((bool)bytesReceived) { //If received more than zero bytes
|
|
uint8_t temp[bytesReceived];
|
|
Wire.readBytes(temp, bytesReceived);
|
|
log_print_buf(temp, bytesReceived);
|
|
}
|
|
}
|