Picadae hardware and control code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

usiTwiSlave.h 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /********************************************************************************
  2. Header file for the USI TWI Slave driver.
  3. Created by Donald R. Blake
  4. donblake at worldnet.att.net
  5. ---------------------------------------------------------------------------------
  6. Created from Atmel source files for Application Note AVR312: Using the USI Module
  7. as an I2C slave.
  8. This program is free software; you can redistribute it and/or modify it under the
  9. terms of the GNU General Public License as published by the Free Software
  10. Foundation; either version 2 of the License, or (at your option) any later
  11. version.
  12. This program is distributed in the hope that it will be useful, but WITHOUT ANY
  13. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  14. PARTICULAR PURPOSE. See the GNU General Public License for more details.
  15. ---------------------------------------------------------------------------------
  16. Change Activity:
  17. Date Description
  18. ------ -------------
  19. 15 Mar 2007 Created.
  20. ********************************************************************************/
  21. #ifndef _USI_TWI_SLAVE_H_
  22. #define _USI_TWI_SLAVE_H_
  23. /********************************************************************************
  24. includes
  25. ********************************************************************************/
  26. #include <stdbool.h>
  27. /********************************************************************************
  28. prototypes
  29. ********************************************************************************/
  30. void usiTwiSlaveInit( uint8_t );
  31. void usiTwiTransmitByte( uint8_t );
  32. uint8_t usiTwiReceiveByte( void );
  33. bool usiTwiDataInReceiveBuffer( void );
  34. //void (*_onTwiDataRequest)(void);
  35. //extern request_func_t _onTwiDataRequest;
  36. bool usiTwiDataInTransmitBuffer(void);
  37. uint8_t usiTwiAmountDataInReceiveBuffer(void);
  38. // on_XXX handler pointers
  39. //void (*usi_onRequestPtr)(void);
  40. //void (*usi_onReceiverPtr)(uint8_t);
  41. typedef void (*request_func_t)(void);
  42. typedef void (*receive_func_t)(uint8_t);
  43. extern request_func_t usi_onRequestPtr;
  44. extern receive_func_t usi_onReceiverPtr;
  45. /********************************************************************************
  46. driver buffer definitions
  47. ********************************************************************************/
  48. // permitted RX buffer sizes: 1, 2, 4, 8, 16, 32, 64, 128 or 256
  49. #ifndef TWI_RX_BUFFER_SIZE
  50. #define TWI_RX_BUFFER_SIZE ( 16 )
  51. #endif
  52. #define TWI_RX_BUFFER_MASK ( TWI_RX_BUFFER_SIZE - 1 )
  53. #if ( TWI_RX_BUFFER_SIZE & TWI_RX_BUFFER_MASK )
  54. # error TWI RX buffer size is not a power of 2
  55. #endif
  56. // permitted TX buffer sizes: 1, 2, 4, 8, 16, 32, 64, 128 or 256
  57. #ifndef TWI_TX_BUFFER_SIZE
  58. #define TWI_TX_BUFFER_SIZE ( 16 )
  59. #endif
  60. #define TWI_TX_BUFFER_MASK ( TWI_TX_BUFFER_SIZE - 1 )
  61. #if ( TWI_TX_BUFFER_SIZE & TWI_TX_BUFFER_MASK )
  62. # error TWI TX buffer size is not a power of 2
  63. #endif
  64. #endif // ifndef _USI_TWI_SLAVE_H_