| LUFA Library 140302 |

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Enumerations | Functions
TWI_AVR8.h File Reference

TWI Peripheral Driver (AVR8) More...

`#include "../../../Common/Common.h"`
`#include <stdio.h>`
`#include <util/twi.h>`

## Macros
#define | TWI_ADDRESS_READ 0x01
#define | TWI_ADDRESS_WRITE 0x00
#define | TWI_BIT_PRESCALE_1 ((0 << TWPS1) | (0 << TWPS0))
#define | TWI_BIT_PRESCALE_16 ((1 << TWPS1) | (0 << TWPS0))
#define | TWI_BIT_PRESCALE_4 ((0 << TWPS1) | (1 << TWPS0))
#define | TWI_BIT_PRESCALE_64 ((1 << TWPS1) | (1 << TWPS0))
#define | TWI_BITLENGTH_FROM_FREQ(Prescale, Frequency) ((((F_CPU / (Prescale)) / (Frequency)) - 16) / 2)
#define | TWI_DEVICE_ADDRESS_MASK 0xFE

## Enumerations
enum | TWI_ErrorCodes_t { TWI_ERROR_NoError = 0, TWI_ERROR_BusFault = 1, TWI_ERROR_BusCaptureTimeout = 2, TWI_ERROR_SlaveResponseTimeout = 3, TWI_ERROR_SlaveNotReady = 4, TWI_ERROR_SlaveNAK = 5, TWI_ERROR_NoError = 0, TWI_ERROR_BusFault = 1, TWI_ERROR_BusCaptureTimeout = 2, TWI_ERROR_SlaveResponseTimeout = 3, TWI_ERROR_SlaveNotReady = 4, TWI_ERROR_SlaveNAK = 5 }

## Functions
static void | TWI_Disable (void) ATTR_ALWAYS_INLINE
static void | TWI_Init (const uint8_t Prescale, const uint8_t BitLength) ATTR_ALWAYS_INLINE
uint8_t | TWI_ReadPacket (const uint8_t SlaveAddress, const uint8_t TimeoutMS, const uint8_t *InternalAddress, uint8_t InternalAddressLen, uint8_t *Buffer, uint8_t Length) ATTR_NON_NULL_PTR_ARG(3)
bool | TWI_ReceiveByte (uint8_t *const Byte, const bool LastByte) ATTR_NON_NULL_PTR_ARG(1)
bool | TWI_SendByte (const uint8_t Byte)
uint8_t | TWI_StartTransmission (const uint8_t SlaveAddress, const uint8_t TimeoutMS)
static void | TWI_StopTransmission (void) ATTR_ALWAYS_INLINE
uint8_t | TWI_WritePacket (const uint8_t SlaveAddress, const uint8_t TimeoutMS, const uint8_t *InternalAddress, uint8_t InternalAddressLen, const uint8_t *Buffer, uint8_t Length) ATTR_NON_NULL_PTR_ARG(3)

## Detailed Description

On-chip TWI driver for the 8-bit AVR microcontrollers.

Note
  This file should not be included directly. It is automatically included as needed by the TWI driver dispatch header located in LUFA/Drivers/Peripheral/TWI.h.