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.

66 satır
2.1KB

  1. /******************************************************************
  2. * EasyTransferI2C Arduino Library
  3. * details and example sketch:
  4. * http://www.billporter.info/easytransfer-arduino-library/
  5. *
  6. * Brought to you by:
  7. * Mathieu Alorent
  8. * Forked from
  9. * Bill Porter
  10. * www.billporter.info
  11. *
  12. * See Readme for other info and version history
  13. *
  14. *
  15. *This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or(at your option) any later version.
  16. This program is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. GNU General Public License for more details.
  20. <http://www.gnu.org/licenses/>
  21. *
  22. *This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
  23. *To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or
  24. *send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
  25. ******************************************************************/
  26. #ifndef EasyTransferI2C_h
  27. #define EasyTransferI2C_h
  28. //make it a little prettier on the front end.
  29. #define details(name) (byte*)&name,sizeof(name)
  30. //Not neccessary, but just in case.
  31. #if ARDUINO > 22
  32. #include "Arduino.h"
  33. #else
  34. #include "WProgram.h"
  35. #endif
  36. #include "HardwareSerial.h"
  37. //#include <NewSoftSerial.h>
  38. #include <math.h>
  39. #include <stdio.h>
  40. #include <stdint.h>
  41. #include <avr/io.h>
  42. #include <Wire.h>
  43. class EasyTransferI2C {
  44. public:
  45. void begin(uint8_t *, uint8_t, TwoWire *theSerial);
  46. void sendData(uint8_t address);
  47. boolean receiveData();
  48. private:
  49. TwoWire *_serial;
  50. //NewSoftSerial *_serial;
  51. uint8_t * address; //address of struct
  52. uint8_t size; //size of struct
  53. uint8_t * rx_buffer; //address for temporary storage and parsing buffer
  54. uint8_t rx_array_inx; //index for RX parsing buffer
  55. uint8_t rx_len; //RX packet length according to the packet
  56. uint8_t calc_CS; //calculated Chacksum
  57. };
  58. #endif