ArduboyI2C Library
|
An I2C library for Arduboy multiplayer games. More...
#include <avr/interrupt.h>
#include <avr/power.h>
#include <util/twi.h>
#include <stdint.h>
Go to the source code of this file.
Classes | |
class | I2C |
Macros | |
#define | I2C_FREQUENCY 100000 |
The initial I2C frequency. | |
#define | I2C_BUFFER_SIZE 32 |
The size of the buffer used for writes/target (slave) operations. | |
#define | I2C_BUS_BUSY_CHECKS 16 |
The amount of times the bus is checked before continuing with a read/write operation. | |
#define | I2C_SCL_PIN PIND |
The pin on which the SCL line is connected. | |
#define | I2C_SCL_BIT PIND0 |
The bit of the pin on which the SCL line is connected. | |
#define | I2C_SDA_PIN PIND |
The pin on which the SDA line is connected. | |
#define | I2C_SDA_BIT PIND1 |
The bit of the pin on which the sda line is connected. | |
#define | I2C_MAX_PLAYERS |
The maxmimum number of players in the handshake/lobby. | |
#define | TW_SUCCESS 0xFF |
Error code used to mean success, returned by I2C::getTWError(). | |
#define | I2C_HANDSHAKE_FAILED 0xFE |
Error code RETURNED by I2C::handshake, meaning the handshake has already been completed. | |
#define | I2C_MAX_ADDRESSES 112 |
The maximum amount of addresses available to a device. | |
#define | I2C_LIB_VER 20000 |
I2C library version. | |
An I2C library for Arduboy multiplayer games.
#define I2C_BUFFER_SIZE 32 |
The size of the buffer used for writes/target (slave) operations.
Defaults to 32. If more than 32 bytes are needed for writes/target (slave) operations, increase. If more RAM is needed, decrease.
#define I2C_BUS_BUSY_CHECKS 16 |
The amount of times the bus is checked before continuing with a read/write operation.
Defaults to 16. Fixes design flaw where TWI hardware does not check if the bus has become busy during a stop interrupt, so if multiple targets (slaves) receive the stop interrupt right before they become the controller (master) and send a start, they all will think the bus is free and clobber each other. Can be set to 0 when there is only one controller (master). Increase if the game ever freezes. More information: https://www.robotroom.com/Atmel-AVR-TWI-I2C-Multi-Master-Problem.html
#define I2C_FREQUENCY 100000 |
The initial I2C frequency.
Defaults to 100000 Hz.
Standard frequencies:
100000 Hz - Standard Mode
400000 Hz - Fast Mode
#define I2C_LIB_VER 20000 |
I2C library version.
For a given version x.y.z, the library version will be in the form xxxyyzz with no leading zeros on x.
#define I2C_MAX_ADDRESSES 112 |
The maximum amount of addresses available to a device.
I2C uses a 7-bit addressing scheme with 127 available unique addresses. However, addresses 0-7 and 120-127 are reserved by the standard and should not be used. This leaves 112 addresses for devices to use.
#define I2C_MAX_PLAYERS |
The maxmimum number of players in the handshake/lobby.
Cannot be more than I2C_MAX_ADDRESSES.
#define I2C_SCL_BIT PIND0 |
The bit of the pin on which the SCL line is connected.
Defaults to PIND0.
#define I2C_SCL_PIN PIND |
The pin on which the SCL line is connected.
Defaults to PIND.
#define I2C_SDA_BIT PIND1 |
The bit of the pin on which the sda line is connected.
Defaults to PIND1.
#define I2C_SDA_PIN PIND |
The pin on which the SDA line is connected.
Defaults to PIND.