Skip to content

Instantly share code, notes, and snippets.

@johnnyman727
Created July 18, 2016 15:58
Show Gist options
  • Save johnnyman727/4d11cf82f6f2f5aa43685e4f0eb556f4 to your computer and use it in GitHub Desktop.
Save johnnyman727/4d11cf82f6f2f5aa43685e4f0eb556f4 to your computer and use it in GitHub Desktop.

Construction

let mut tessel = Tessel::new();

#I2C

// Perhaps we want an Option here for frequency?
let i2c = tessel.port.a.I2C(address: u8, frequency: u32);
// Sending a buffer, no return val
i2c.send(buf: [u8]);
// Reading data, return buffer
let buf:u8 = i2c.read(readLength: u8);
// Writing and reading simultaenously
let buf:u8 = i2c.transfer(buf: [u8], readLength: u8);

#SPI

// Perhaps we want an Option here?
let spi = tessel.port.a.SPI(baudrate: u32);
// Sending a buffer, no return val
spi.send(buf: [u8]);
// Reading data, return buffer
let buf:u8 = spi.receive(readLength: u8);
// Transfering and reading
let buf:u8 = spi.read(buf: [u8], readLength: u8);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment