00001 /******************************************************************************** 00002 00003 Header file for the USI TWI Slave driver. 00004 00005 Created by Donald R. Blake 00006 donblake at worldnet.att.net 00007 00008 --------------------------------------------------------------------------------- 00009 00010 Created from Atmel source files for Application Note AVR312: Using the USI Module 00011 as an I2C slave. 00012 00013 This program is free software; you can redistribute it and/or modify it under the 00014 terms of the GNU General Public License as published by the Free Software 00015 Foundation; either version 2 of the License, or (at your option) any later 00016 version. 00017 00018 This program is distributed in the hope that it will be useful, but WITHOUT ANY 00019 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 00020 PARTICULAR PURPOSE. See the GNU General Public License for more details. 00021 00022 --------------------------------------------------------------------------------- 00023 00024 Change Activity: 00025 00026 Date Description 00027 ------ ------------- 00028 15 Mar 2007 Created. 00029 00030 ********************************************************************************/ 00031 00032 00033 00034 #ifndef _USI_TWI_SLAVE_H_ 00035 #define _USI_TWI_SLAVE_H_ 00036 00037 00038 00039 /******************************************************************************** 00040 00041 includes 00042 00043 ********************************************************************************/ 00044 00045 #include <stdbool.h> 00046 00047 00048 00049 /******************************************************************************** 00050 00051 prototypes 00052 00053 ********************************************************************************/ 00054 00055 void usiTwiSlaveInit( uint8_t ); 00056 void usiTwiTransmitByte( uint8_t ); 00057 uint8_t usiTwiReceiveByte( void ); 00058 bool usiTwiDataInReceiveBuffer( void ); 00059 00060 00061 00062 /******************************************************************************** 00063 00064 driver buffer definitions 00065 00066 ********************************************************************************/ 00067 00068 // permitted RX buffer sizes: 1, 2, 4, 8, 16, 32, 64, 128 or 256 00069 00070 #define TWI_RX_BUFFER_SIZE ( 16 ) 00071 #define TWI_RX_BUFFER_MASK ( TWI_RX_BUFFER_SIZE - 1 ) 00072 00073 #if ( TWI_RX_BUFFER_SIZE & TWI_RX_BUFFER_MASK ) 00074 # error TWI RX buffer size is not a power of 2 00075 #endif 00076 00077 // permitted TX buffer sizes: 1, 2, 4, 8, 16, 32, 64, 128 or 256 00078 00079 #define TWI_TX_BUFFER_SIZE ( 16 ) 00080 #define TWI_TX_BUFFER_MASK ( TWI_TX_BUFFER_SIZE - 1 ) 00081 00082 #if ( TWI_TX_BUFFER_SIZE & TWI_TX_BUFFER_MASK ) 00083 # error TWI TX buffer size is not a power of 2 00084 #endif 00085 00086 00087 00088 #endif // ifndef _USI_TWI_SLAVE_H_