28 lines
618 B
C++
28 lines
618 B
C++
#include <Arduino.h>
|
|
#include <i2c_device.h>
|
|
|
|
#define SLAVE_ADDR 0x08
|
|
#define BUFFER_SIZE 256
|
|
|
|
i2c_device i2c = i2c_device(Wire, SLAVE_ADDR); // Use default Wire (I2C1)
|
|
|
|
uint8_t dataBuffer[BUFFER_SIZE];
|
|
|
|
void setup() {
|
|
Wire.begin();
|
|
Wire.setClock(1000000); // Set I2C clock speed to 1 MHz
|
|
|
|
// Fill buffer with test data
|
|
for (int i = 0; i < BUFFER_SIZE; i++) {
|
|
dataBuffer[i] = i;
|
|
}
|
|
|
|
delay(1000); // Allow slave to initialize
|
|
}
|
|
|
|
void loop() {
|
|
i2c.write(dataBuffer, BUFFER_SIZE); // Send full 256 bytes in one transaction
|
|
|
|
delay(10); // Small delay before next transmission
|
|
}
|