twi_basics/twi_basics.c File Reference

#include "twi_basics.h"
#include <util/twi.h>

Go to the source code of this file.

Defines

#define TW_CONF_MASK   ((1<<TWWC) | (1<<TWEN) | (1<<TWIE) | (1<<1) )
#define TW_SEND_CMD(cmd)   TWCR = (TWCR & TW_CONF_MASK ) | (cmd)
 sends command leaving CONF bits unchanged

Functions

void wait ()
twi_status twi_start ()
twi_status twi_send (uint8_t data)
twi_status twi_receive (uint8_t *where, uint8_t ack)
void twi_stop ()

Detailed Description

Author:
Krzysztof Wesolowski
Date:
September 09, 2009

Definition in file twi_basics.c.


Define Documentation

#define TW_CONF_MASK   ((1<<TWWC) | (1<<TWEN) | (1<<TWIE) | (1<<1) )

those bits should be unchanged while writing commands to TWCR, so we will simple write (TCWR & TW_CONF_MASK) | Command

Definition at line 12 of file twi_basics.c.


Function Documentation

twi_status twi_receive ( uint8_t *  where,
uint8_t  ack 
)

Receive one byte over TWI interface

Parameters:
where Pointer to location where received data we'll be stored
ack Set to nonzero to send ACK after receiving. Usually it continues transfer.
Returns:
Status of TWI after operation extracted from TWSR

Definition at line 54 of file twi_basics.c.

References TW_SEND_CMD, and wait().

Referenced by ds1338_readBufferFromNVRAM(), and ds1338_readByteFromNVRAM().

twi_status twi_send ( uint8_t  data  ) 

Sends one byte over TWI interface

Parameters:
data Data to be send
Returns:
Status of TWI after operation extracted from TWSR

Definition at line 40 of file twi_basics.c.

References TW_SEND_CMD, and wait().

Referenced by ds1338_writeBufferToNVRAM(), and ds1338_writeByteToNVRAM().

twi_status twi_start (  ) 

Sends start condition

Returns:
Status of TWI after operation extracted from TWSR

Definition at line 28 of file twi_basics.c.

References TW_SEND_CMD, and wait().

void twi_stop (  ) 

Sends STOP condition. Take a look at unusual busy-wait loop (Stop doesn't affect TWINT)

Definition at line 68 of file twi_basics.c.

References TW_SEND_CMD.

Referenced by ds1338_readBufferFromNVRAM(), ds1338_readByteFromNVRAM(), ds1338_writeBufferToNVRAM(), and ds1338_writeByteToNVRAM().

void wait (  ) 

Waits until last TWI operation is completed

Definition at line 19 of file twi_basics.c.

Referenced by twi_receive(), twi_send(), and twi_start().


Generated on Wed Sep 9 20:37:11 2009 for DS1338Library by  doxygen 1.6.1