00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef twi_h
00021 #define twi_h
00022
00023 #include <inttypes.h>
00024
00025
00026
00027 #ifndef CPU_FREQ
00028 #define CPU_FREQ 16000000L
00029 #endif
00030
00031 #ifndef TWI_FREQ
00032 #define TWI_FREQ 100000L
00033 #endif
00034
00035 #ifndef TWI_BUFFER_LENGTH
00036 #define TWI_BUFFER_LENGTH 32
00037 #endif
00038
00039 #define TWI_READY 0
00040 #define TWI_MRX 1
00041 #define TWI_MTX 2
00042 #define TWI_SRX 3
00043 #define TWI_STX 4
00044
00045 void twi_init(void);
00046 void twi_setAddress(uint8_t);
00047 uint8_t twi_readFrom(uint8_t, uint8_t*, uint8_t);
00048 uint8_t twi_writeTo(uint8_t, uint8_t*, uint8_t, uint8_t);
00049 uint8_t twi_transmit(uint8_t*, uint8_t);
00050 void twi_attachSlaveRxEvent( void (*)(uint8_t*, int) );
00051 void twi_attachSlaveTxEvent( void (*)(void) );
00052 void twi_reply(uint8_t);
00053 void twi_stop(void);
00054 void twi_releaseBus(void);
00055
00056 #endif
00057