26 #include <avr/interrupt.h> 27 #include <compat/twi.h> 31 #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) 35 #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) 38 #include "pins_arduino.h" 82 TWBR = ((F_CPU /
TWI_FREQ) - 16) / 2;
90 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA);
102 TWCR &= ~(_BV(TWEN) | _BV(TWIE) | _BV(TWEA));
129 TWBR = ((F_CPU / frequency) - 16) / 2;
188 }
while(TWCR & _BV(TWWC));
189 TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE);
193 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTA);
204 for(i = 0; i < length; ++i){
249 for(i = 0; i < length; ++i){
270 }
while(TWCR & _BV(TWWC));
271 TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE);
275 TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE) | _BV(TWSTA);
317 for(i = 0; i < length; ++i){
357 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT) | _BV(TWEA);
359 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT);
372 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO);
376 while(TWCR & _BV(TWSTO)){
393 TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT);
426 TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;
435 case TW_MT_DATA_NACK:
456 case TW_MR_DATA_NACK:
466 TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;
477 case TW_SR_GCALL_ACK:
478 case TW_SR_ARB_LOST_SLA_ACK:
479 case TW_SR_ARB_LOST_GCALL_ACK:
487 case TW_SR_GCALL_DATA_ACK:
510 case TW_SR_DATA_NACK:
511 case TW_SR_GCALL_DATA_NACK:
518 case TW_ST_ARB_LOST_SLA_ACK:
544 case TW_ST_DATA_NACK:
545 case TW_ST_LAST_DATA:
GLuint GLsizei GLsizei * length
void twi_releaseBus(void)
GLvoid *typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
void twi_attachSlaveRxEvent(void(*function)(uint8_t *, int))
uint8_t twi_transmit(const uint8_t *data, uint8_t length)
static volatile uint8_t twi_txBufferLength
static volatile uint8_t twi_rxBufferIndex
static void(* twi_onSlaveReceive)(uint8_t *, int)
static volatile uint8_t twi_state
void twi_setAddress(uint8_t address)
void twi_setFrequency(uint32_t frequency)
uint8_t twi_readFrom(uint8_t address, uint8_t *data, uint8_t length, uint8_t sendStop)
static volatile uint8_t twi_slarw
static uint8_t twi_rxBuffer[TWI_BUFFER_LENGTH]
static uint8_t twi_txBuffer[TWI_BUFFER_LENGTH]
#define TWI_BUFFER_LENGTH
static void(* twi_onSlaveTransmit)(void)
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
static volatile uint8_t twi_masterBufferLength
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
static volatile uint8_t twi_inRepStart
static volatile uint8_t twi_txBufferIndex
void twi_reply(uint8_t ack)
void digitalWrite(uint8_t, uint8_t)
static volatile uint8_t twi_sendStop
uint8_t twi_writeTo(uint8_t address, uint8_t *data, uint8_t length, uint8_t wait, uint8_t sendStop)
static uint8_t twi_masterBuffer[TWI_BUFFER_LENGTH]
static volatile uint8_t twi_masterBufferIndex
void twi_attachSlaveTxEvent(void(*function)(void))
static volatile uint8_t twi_error