Stream large array to I2C slave

Here's tested and working code to send a large I2C transfer without allocating a larger transmit buffer. This code assumes that you have included Wire.h and called Wire.begin() in setup() to initialize the SERCOM and set up the pins. It also assumes that you're using SERCOM3 for I2C / Wire, which is default for the Zero. It doesn't do any kind of error checking or any of that, but it certainly could be adapted to do so.

void writeLargeArray(byte deviceaddress, unsigned int datasize, uint8_t* data) {

 // uses raw I2C writes, rather than use the txbuffer
 sercom3.startTransmissionWIRE(0x30, WIRE_WRITE_FLAG);

 for (unsigned int i = 0; i < datasize; i++) {

// send one byte at a time from the array to the I2C device
   sercom3.sendDataMasterWIRE((byte) data[i]);
 }

// stop sending the data
 sercom3.prepareCommandBitsWire(WIRE_MASTER_ACT_STOP);

}