PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
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.

54 satır
1.5KB

  1. /*
  2. twi.h - TWI/I2C library for Wiring & Arduino
  3. Copyright (c) 2006 Nicholas Zambetti. All right reserved.
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with this library; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  15. */
  16. #ifndef twi_h
  17. #define twi_h
  18. #include <inttypes.h>
  19. //#define ATMEGA8
  20. #ifndef TWI_FREQ
  21. #define TWI_FREQ 100000L
  22. #endif
  23. #ifndef TWI_BUFFER_LENGTH
  24. #define TWI_BUFFER_LENGTH 32
  25. #endif
  26. #define TWI_READY 0
  27. #define TWI_MRX 1
  28. #define TWI_MTX 2
  29. #define TWI_SRX 3
  30. #define TWI_STX 4
  31. void twi_init(void);
  32. void twi_setAddress(uint8_t);
  33. uint8_t twi_readFrom(uint8_t, uint8_t*, uint8_t, uint8_t);
  34. uint8_t twi_writeTo(uint8_t, uint8_t*, uint8_t, uint8_t, uint8_t);
  35. uint8_t twi_transmit(const uint8_t*, uint8_t);
  36. void twi_attachSlaveRxEvent( void (*)(uint8_t*, int) );
  37. void twi_attachSlaveTxEvent( void (*)(void) );
  38. void twi_reply(uint8_t);
  39. void twi_stop(void);
  40. void twi_releaseBus(void);
  41. #endif