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.

EasyTransfer.h 2.1KB

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