twi_drv.h

Go to the documentation of this file.
00001 /*H**************************************************************************
00002 * $RCSfile: twi_drv.h,v $         
00003 *----------------------------------------------------------------------------
00004 * Copyright (c) 2003 Atmel.
00005 *----------------------------------------------------------------------------
00006 * RELEASE:      $Name: avr-can11-lib-mcu-0_0_3 $      
00007 * REVISION:     $Revision: 1.2 $     
00008 * FILE_CVSID:   $Id: twi_drv.h,v 1.2 2004/02/10 06:48:28 jberthy Exp $       
00009 *----------------------------------------------------------------------------
00010 * PURPOSE: 
00011 * Provide Uart driver
00012 *****************************************************************************/
00013 
00014 #ifndef _TWI_DRV_H_
00015 #define _TWI_DRV_H_
00016 
00017 #define MSK_TWCR_TWINT   0x80
00018 #define MSK_TWCR_TWEA    0x40 
00019 #define MSK_TWCR_TWSTA   0x20 
00020 #define MSK_TWCR_TWSTO   0x10 
00021 #define MSK_TWCR_TWEN    0x04
00022 #define MSK_TWCR_TWIE    0x01
00023 
00024 
00025 #define Twi_set_address(address) (TWAR = address)
00026 #define Twi_get_address()        (TWAR)
00027 #define Twi_set_data(data)       (TWDR = data)
00028 #define Twi_set_aa()             (TWCR |= MSK_TWCR_TWEA&(~MSK_TWCR_TWINT))
00029 #define Twi_clear_aa()           (TWCR &= (~MSK_TWCR_TWEA)&(~MSK_TWCR_TWINT))   
00030 #define Twi_get_status()         (TWSR)
00031 #define Twi_clear_start()        (TWCR &= (~MSK_TWCR_TWSTA)&(~MSK_TWCR_TWINT) )
00032 #define Twi_set_start()          (TWCR |= MSK_TWCR_TWSTA)
00033 #define Twi_set_stop()           (TWCR |= MSK_TWCR_TWSTO)
00034 #define Twi_clear_stop()         (TWCR &= ~MSK_TWCR_TWSTO)
00035 #define Twi_get_data()           (TWDR)
00036 #define Twi_clear_si()           (TWCR |= MSK_TWCR_TWINT)
00037 #define Twi_set_baudrate(baudrate)(TWBR = baudrate)
00038 #define Twi_wait_hw_stop()       while((TWCR & MSK_TWCR_TWSTO)==MSK_TWCR_TWSTO)
00039 #define Twi_wait_event()         while(((TWCR & MSK_TWCR_TWINT))!= MSK_TWCR_TWINT)
00040 #define Disable_twi_interrupt()  (TWCR &= ~MSK_TWCR_TWIE)
00041 #define Enable_twi_interrupt()   (TWCR |= MSK_TWCR_TWIE)
00042 #define Twi_init_hw(arg)         (TWCR = arg)
00043 
00044 
00045 #define Twi_repeated_start()    (TWCR |= 0xA4)
00046 
00047 //16 bits data length
00048 #define TWI_BIG_FRAME
00049 
00050 #endif

Generated on Mon Dec 1 11:12:20 2008 for AVR498 : Atmel BLDC control on ATAVRMC301 with ATtiny861 by  doxygen 1.5.4