Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions libraries/I3C/examples/BasicBegin/BasicBegin.ino
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
#include <I3C.h>

// Choose the bus instance available on your board.

#define I3C_BUS I3C1Bus

void setup() {
Serial.begin(115200);
while (!Serial) {}

Serial.println("I3C Basic Begin");

// Option 1: use default board I3C pins
if (!I3C_BUS.begin(1000000)) {
if (!I3C.begin(1000000)) {
Serial.println("Failed to initialize I3C bus");
while (1) {}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "I3C.h"

#define I3C_BUS I3C1Bus
static I3CDiscoveredDevice devices[8];

void printHex2(uint8_t v) {
Expand All @@ -15,13 +14,13 @@ void setup() {

Serial.println("=== Controller Write / Target Receive ===");

if (!I3C_BUS.begin(I3C_SDA, I3C_SCL, 1000000U)) {
if (!I3C.begin(I3C_SDA, I3C_SCL, 1000000U)) {
Serial.println("begin() failed");
while (1) {}
}

size_t found = 0;
int rc = I3C_BUS.discover(devices, 8, &found);
int rc = I3C.discover(devices, 8, &found);

if (rc != 0 || found == 0) {
Serial.println("No target found");
Expand All @@ -43,7 +42,7 @@ void setup() {
0x0D, 0x0E, 0x0F, 0x10
};

int wr = I3C_BUS.write(da, tx, sizeof(tx), 1000);
int wr = I3C.write(da, tx, sizeof(tx), 1000);
Serial.print("write rc = ");
Serial.println(wr);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "I3C.h"

#define I3C_BUS I3C1Bus
static uint8_t rxBuf[16];

void printHex2(uint8_t v) {
Expand All @@ -19,21 +18,21 @@ void setup() {
cfg.identifier = 0x62;
cfg.mipiIdentifier = 0x1;

if (!I3C_BUS.beginTarget(I3C_SDA, I3C_SCL, cfg)) {
if (!I3C.beginTarget(I3C_SDA, I3C_SCL, cfg)) {
Serial.println("beginTarget failed");
while (1) {}
}

while (!I3C_BUS.hasAddress()) {
while (!I3C.hasAddress()) {
delay(10);
}

Serial.print("DA = 0x");
Serial.println(I3C_BUS.address(), HEX);
Serial.println(I3C.address(), HEX);

HAL_I3C_FlushAllFifo(I3C_BUS.halHandle());
HAL_I3C_FlushAllFifo(I3C.halHandle());

int rc = I3C_BUS.receive(rxBuf, sizeof(rxBuf), 10000);
int rc = I3C.receive(rxBuf, sizeof(rxBuf), 10000);
Serial.print("receive rc = ");
Serial.println(rc);

Expand Down
7 changes: 2 additions & 5 deletions libraries/I3C/examples/DeviceReady/DeviceReady.ino
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
#include <I3C.h>

#define I3C_BUS I3C1Bus


void setup() {
Serial.begin(115200);
while (!Serial) {}

Serial.println("I3C Device Ready Example");

if (!I3C_BUS.begin(1000000)) {
if (!I3C.begin(1000000)) {
Serial.println("Failed to initialize I3C bus");
while (1) {}
}

for (uint8_t addr = 1; addr < 0x7F; ++addr) {

bool i3cReady = I3C_BUS.isI3CDeviceReady(addr);
bool i3cReady = I3C.isI3CDeviceReady(addr);
if (i3cReady) {
Serial.print("I3C device at DA 0x");
Serial.print(addr, HEX);
Expand Down
4 changes: 2 additions & 2 deletions libraries/I3C/examples/ScanBus/ScanBus.ino
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ void setup() {

Serial.println("=== I3C ScanBus ===");

if (!I3C1Bus.begin(I3C_SDA, I3C_SCL, 1000000U)) {
if (!I3C.begin(I3C_SDA, I3C_SCL, 1000000U)) {
Serial.println("begin() failed");
while (1) {}
}

size_t found = 0;

int rc = I3C1Bus.discover(devices, 8, &found);
int rc = I3C.discover(devices, 8, &found);

Serial.print("discover rc = ");
Serial.println(rc);
Expand Down
17 changes: 8 additions & 9 deletions libraries/I3C/examples/TargetIBI/Controller/Controller.ino
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "I3C.h"

#define I3C_BUS I3C1Bus
static I3CDiscoveredDevice devices[8];
static volatile bool callbackSeen = false;

Expand All @@ -24,13 +23,13 @@ void setup() {

Serial.println("=== Controller IBI Example ===");

if (!I3C_BUS.begin(I3C_SDA, I3C_SCL, 1000000U)) {
if (!I3C.begin(I3C_SDA, I3C_SCL, 1000000U)) {
Serial.println("begin() failed");
while (1) {}
}

size_t found = 0;
int rc = I3C_BUS.discover(devices, 8, &found);
int rc = I3C.discover(devices, 8, &found);

if (rc != 0 || found == 0) {
Serial.println("No target found");
Expand All @@ -39,29 +38,29 @@ void setup() {

uint8_t da = devices[0].dynAddr;

I3C_BUS.onIbi(myIbiCallback, (void *)&callbackSeen);
I3C.onIbi(myIbiCallback, (void *)&callbackSeen);

rc = I3C_BUS.enableIbi(1, da, false, false, 1000);
rc = I3C.enableIbi(1, da, false, false, 1000);
Serial.print("enableIbi rc = ");
Serial.println(rc);

rc = I3C_BUS.enableControllerEvents();
rc = I3C.enableControllerEvents();
Serial.print("enableControllerEvents rc = ");
Serial.println(rc);

Serial.println("Waiting for IBI...");
}

void loop() {
if (I3C_BUS.hasIbi()) {
if (I3C.hasIbi()) {
I3CControllerIbiInfo ibi{};
if (I3C_BUS.peekIbi(ibi)) {
if (I3C.peekIbi(ibi)) {
Serial.print("peekIbi source DA = 0x");
printHex2(ibi.sourceDa);
Serial.println();
}

if (I3C_BUS.readIbi(ibi)) {
if (I3C.readIbi(ibi)) {
Serial.print("readIbi source DA = 0x");
printHex2(ibi.sourceDa);
Serial.println();
Expand Down
10 changes: 4 additions & 6 deletions libraries/I3C/examples/TargetIBI/Target/Target.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "I3C.h"

#define I3C_BUS I3C1Bus

void setup() {
Serial.begin(115200);
while (!Serial) {}
Expand All @@ -15,21 +13,21 @@ void setup() {
cfg.ibiRequest = true;
cfg.ibiPayload = false;

if (!I3C_BUS.beginTarget(I3C_SDA, I3C_SCL, cfg)) {
if (!I3C.beginTarget(I3C_SDA, I3C_SCL, cfg)) {
Serial.println("beginTarget failed");
while (1) {}
}

while (!I3C_BUS.hasAddress()) {
while (!I3C.hasAddress()) {
delay(10);
}

Serial.print("DA = 0x");
Serial.println(I3C_BUS.address(), HEX);
Serial.println(I3C.address(), HEX);

delay(2000);

int rc = I3C_BUS.sendIbi(nullptr, 0, 1000);
int rc = I3C.sendIbi(nullptr, 0, 1000);
Serial.print("sendIbi rc = ");
Serial.println(rc);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "I3C.h"

#define I3C_BUS I3C1Bus
static I3CDiscoveredDevice devices[8];

void printHex2(uint8_t v) {
Expand All @@ -15,13 +14,13 @@ void setup() {

Serial.println("=== Controller Trigger Target Events ===");

if (!I3C_BUS.begin(I3C_SDA, I3C_SCL, 1000000U)) {
if (!I3C.begin(I3C_SDA, I3C_SCL, 1000000U)) {
Serial.println("begin() failed");
while (1) {}
}

size_t found = 0;
int rc = I3C_BUS.discover(devices, 8, &found);
int rc = I3C.discover(devices, 8, &found);

if (rc != 0 || found == 0) {
Serial.println("No target found");
Expand All @@ -36,13 +35,13 @@ void setup() {

delay(2000);

rc = I3C_BUS.setEvents(da, false, 0x01, 1000); // DISEC INTR
rc = I3C.setEvents(da, false, 0x01, 1000); // DISEC INTR
Serial.print("DISEC(INTR) rc = ");
Serial.println(rc);

delay(5000);

rc = I3C_BUS.setEvents(da, true, 0x01, 1000); // ENEC INTR
rc = I3C.setEvents(da, true, 0x01, 1000); // ENEC INTR
Serial.print("ENEC(INTR) rc = ");
Serial.println(rc);
}
Expand Down
14 changes: 6 additions & 8 deletions libraries/I3C/examples/TargetNotifications/Target/Target.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "I3C.h"

#define I3C_BUS I3C1Bus

void setup() {
Serial.begin(115200);
while (!Serial) {}
Expand All @@ -13,32 +11,32 @@ void setup() {
cfg.identifier = 0x62;
cfg.mipiIdentifier = 0x1;

if (!I3C_BUS.beginTarget(I3C_SDA, I3C_SCL, cfg)) {
if (!I3C.beginTarget(I3C_SDA, I3C_SCL, cfg)) {
Serial.println("beginTarget failed");
while (1) {}
}

while (!I3C_BUS.hasAddress()) {
while (!I3C.hasAddress()) {
delay(10);
}

Serial.print("DA = 0x");
Serial.println(I3C_BUS.address(), HEX);
Serial.println(I3C.address(), HEX);

int rc = I3C_BUS.enableTargetEvents(nullptr, HAL_I3C_IT_INTUPDIE);
int rc = I3C.enableTargetEvents(nullptr, HAL_I3C_IT_INTUPDIE);
Serial.print("enableTargetEvents rc = ");
Serial.println(rc);
}

void loop() {
uint32_t eventId = 0;
if (I3C_BUS.readTargetEvent(eventId)) {
if (I3C.readTargetEvent(eventId)) {
Serial.print("Target event = 0x");
Serial.println(eventId, HEX);

if ((eventId & EVENT_ID_ENEC_DISEC) != 0U) {
I3C_CCCInfoTypeDef info{};
if (HAL_I3C_GetCCCInfo(I3C_BUS.halHandle(), EVENT_ID_ENEC_DISEC, &info) == HAL_OK) {
if (HAL_I3C_GetCCCInfo(I3C.halHandle(), EVENT_ID_ENEC_DISEC, &info) == HAL_OK) {
Serial.print(" HotJoinAllowed = ");
Serial.println(info.HotJoinAllowed ? "YES" : "NO");

Expand Down
Loading
Loading