Advertisement
grist

usiTwiSlave.h

Feb 12th, 2012
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.57 KB | None | 0 0
  1. /********************************************************************************
  2.  
  3. Header file for the USI TWI Slave driver.
  4.  
  5. Created by Donald R. Blake
  6. donblake at worldnet.att.net
  7.  
  8. ---------------------------------------------------------------------------------
  9.  
  10. Created from Atmel source files for Application Note AVR312: Using the USI Module
  11. as an I2C slave.
  12.  
  13. This program is free software; you can redistribute it and/or modify it under the
  14. terms of the GNU General Public License as published by the Free Software
  15. Foundation; either version 2 of the License, or (at your option) any later
  16. version.
  17.  
  18. This program is distributed in the hope that it will be useful, but WITHOUT ANY
  19. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  20. PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  21.  
  22. ---------------------------------------------------------------------------------
  23.  
  24. Change Activity:
  25.  
  26.     Date       Description
  27.    ------      -------------
  28.   15 Mar 2007  Created.
  29.  
  30. ********************************************************************************/
  31.  
  32.  
  33.  
  34. #ifndef _USI_TWI_SLAVE_H_
  35. #define _USI_TWI_SLAVE_H_
  36.  
  37.  
  38.  
  39. /********************************************************************************
  40.  
  41.                                     includes
  42.  
  43. ********************************************************************************/
  44.  
  45. #include <stdbool.h>
  46.  
  47.  
  48.  
  49. /********************************************************************************
  50.  
  51.                                    prototypes
  52.  
  53. ********************************************************************************/
  54.  
  55. void    usiTwiSlaveInit( uint8_t );
  56. void    usiTwiTransmitByte( uint8_t );
  57. uint8_t usiTwiReceiveByte( void );
  58. bool    usiTwiDataInReceiveBuffer( void );
  59.  
  60.  
  61.  
  62. /********************************************************************************
  63.  
  64.                            driver buffer definitions
  65.  
  66. ********************************************************************************/
  67.  
  68. // permitted RX buffer sizes: 1, 2, 4, 8, 16, 32, 64, 128 or 256
  69.  
  70. #define TWI_RX_BUFFER_SIZE  ( 16 )
  71. #define TWI_RX_BUFFER_MASK  ( TWI_RX_BUFFER_SIZE - 1 )
  72.  
  73. #if ( TWI_RX_BUFFER_SIZE & TWI_RX_BUFFER_MASK )
  74. #  error TWI RX buffer size is not a power of 2
  75. #endif
  76.  
  77. // permitted TX buffer sizes: 1, 2, 4, 8, 16, 32, 64, 128 or 256
  78.  
  79. #define TWI_TX_BUFFER_SIZE ( 16 )
  80. #define TWI_TX_BUFFER_MASK ( TWI_TX_BUFFER_SIZE - 1 )
  81.  
  82. #if ( TWI_TX_BUFFER_SIZE & TWI_TX_BUFFER_MASK )
  83. #  error TWI TX buffer size is not a power of 2
  84. #endif
  85.  
  86.  
  87.  
  88. #endif  // ifndef _USI_TWI_SLAVE_H_
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement