Two-Wire Interface

Functions

void twi_set_ack (uint8_t ack)
void twi_interrupt_config (uint8_t cmd)
void twi_send_byte (uint8_t val)
void twi_send_start (void)
void twi_send_stop (void)
void twi_set_prescalar (uint8_t pre)
void twi_wait_twint (void)
uint8_t twi_get_twint (void)
uint8_t twi_get_status (void)
uint8_t twi_get_byte (void)
void twi_set_state (uint8_t val)
uint8_t twi_get_state (void)
uint8_t twi_get_stop (void)
void twi_set_rate (uint8_t rate)
void twi_set_address (uint8_t address)
void twi_set_twint (void)

Function Documentation

uint8_t twi_get_byte ( void   )  [inline]

Return the byte received from the twi transaction

Returns:
Last byte received.
Author:
Andrew H. Fagg
uint8_t twi_get_state ( void   )  [inline]

Get the state of the TWCR register

Returns:
The state of the TWCR register.
Author:
Andrew H. Fagg
uint8_t twi_get_status ( void   )  [inline]

Return the status register

Returns:
The value of the TWI status register.
Author:
Andrew H. Fagg
uint8_t twi_get_stop ( void   )  [inline]

Get the stop state of the TWI device.

Returns:
The stop state: 0 or _BF(TWSTO)
Author:
Andrew H. Fagg
uint8_t twi_get_twint ( void   )  [inline]

Return the TWINT status bit.

Returns:
0: not ready
non-zero (_BV(TWINT)): ready.
Author:
Andrew H. Fagg
void twi_interrupt_config ( uint8_t  cmd  ) 

Configure the TWI interrupt.

Parameters:
cmd TWI_INTERRUPT_ENABLE: enable the twi interrupt
TWI_INTERRUPT_DISABLE: disable
Author:
Andrew H. Fagg
void twi_send_byte ( uint8_t  val  ) 

Place a byte for transmission into the buffer.

Note: Initiates the transmission of the byte immediately.

Parameters:
val Byte value to transmit
Author:
Andrew H. Fagg
void twi_send_start ( void   ) 

Initiate the transmission of the "start" sequence

Note: initiates the transfer of this sequence.

Author:
Andrew H. Fagg
void twi_send_stop ( void   ) 

Initiate the transfer of the the stop sequence

Note: Initiates the actual transfer immediately

Author:
Andrew H. Fagg
void twi_set_ack ( uint8_t  ack  ) 

Set the state of the TWI acknowledgement.

Note: this does not initiate a transmission. A 2nd call is required to do this (e.g., twi_set_ack(), or twi_send_byte())

Parameters:
ack TWI_ACKNOWLEDGE_ENABLE: acknowledge
TWI_ACKNOWLEDGE_DISABLE: do not acknowledge
Author:
Andrew H. Fagg

Set the state of the acknowledgement bit.

Note: this does not initiate a transmission. A 2nd call is required to do this (e.g., twi_set_twint(), or twi_send_byte())

Parameters:
ack TWI_ACKNOWLEDGE_ENABLE: acknowledge
TWI_ACKNOWLEDGE_DISABLE: do not acknowledge
Author:
Andrew H. Fagg
void twi_set_address ( uint8_t  address  )  [inline]

Set the slave address

Parameters:
address Slave address
Author:
Andrew H. Fagg
void twi_set_prescalar ( uint8_t  pre  ) 

Set the clock prescalar for the TWI device.

Parameters:
pre One of: TWI_PRESCALAR_1: divide system clock by 1
TWI_PRESCALAR_4: divide by 4
TWI_PRESCALAR_16: divide by 16
TWI_PRESCALAR_64: divide by 64
Author:
Andrew H. Fagg
void twi_set_rate ( uint8_t  rate  )  [inline]

Set the TWI data transmission rate

Parameters:
rate Transmission rate
Author:
Andrew H. Fagg
void twi_set_state ( uint8_t  val  )  [inline]

Set the state of the TWCR register

Parameters:
val The value to set TWCR to.
Author:
Andrew H. Fagg
void twi_set_twint ( void   )  [inline]

Force the twi device to initiate a transaction immediately. We assume that the device has already been configured

Author:
Andrew H. Fagg
void twi_wait_twint ( void   ) 

Return when the twi device is ready to be serviced. This should only be used in non-interrupt mode.

Author:
Andrew H. Fagg
Generated on Tue Feb 14 00:23:58 2012 for OU Atmel Utilities Library by  doxygen 1.6.3