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