Skip to content
I2C slave library for Atmel AVRs
C Makefile
Branch: master
Clone or download
Latest commit ae740b0 Nov 6, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
I2CSlave.c Initial Commit Mar 22, 2015
I2CSlave.h Initial Commit Mar 22, 2015
LICENSE Create LICENSE Nov 6, 2017
README.md Create README.md Mar 23, 2015
main.c Initial Commit Mar 22, 2015
makefile Initial Commit Mar 22, 2015

README.md

AVR I2C Slave Library

This library provides interrupt-based I2C slave functionality for Atmel 8-bit microcontrollers equipped with a TWI peripheral.

It is somewhat based on an existing library found here: https://github.com/devthrash/I2C-slave-lib

Files

  • I2CSlave.c -- Implements init/stop, and interrupt-based receive and request logic
  • I2CSlave.h -- Function prototypes and a convience method for transmitting data

Usage

Provide callbacks for receiving and handling requests in your application code. eg:

void I2C_received(uint8_t data);
void I2C_requested();

I2C_setCallbacks(I2C_received, I2C_requested);

The library calls the received callback for each byte the master transmits to the slave. The library calls the requested callback for each byte the master attempts to read from the slave.

Init the I2C slave with the slave address

I2C_init(I2C_ADDRESS);

Transmitting data to the master when requested

I2C_transmitByte(data);

Example

The example in main.c implements a sample application in which the slave can receive a byte, and then will echo the byte when requested.

To compile: make

You can’t perform that action at this time.