From e8b0c69ebbe3ff89c5322d92b8e6c83b30c3b954 Mon Sep 17 00:00:00 2001 From: "Michael P. Flaga" Date: Tue, 4 Feb 2014 21:22:44 -0500 Subject: [PATCH 1/2] added support for AVR_ATmega32U4 USB equivalent to HardwareSerial such as leonardo's and Teensy's --- EasyTransfer/EasyTransfer.cpp | 12 ++++++++---- EasyTransfer/EasyTransfer.h | 20 +++++++++++++++++--- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/EasyTransfer/EasyTransfer.cpp b/EasyTransfer/EasyTransfer.cpp index 4d9d672..0480eb4 100644 --- a/EasyTransfer/EasyTransfer.cpp +++ b/EasyTransfer/EasyTransfer.cpp @@ -1,14 +1,18 @@ #include "EasyTransfer.h" - - - +#if defined(SoftwareSerial_h) +void EasyTransfer::begin(uint8_t * ptr, uint8_t length, SoftSerial *theSerial){ +#elif defined(__AVR_ATmega32U4__) //Captures address and size of struct +void EasyTransfer::begin(uint8_t * ptr, uint8_t length, Serial_ *theSerial){ +#else void EasyTransfer::begin(uint8_t * ptr, uint8_t length, HardwareSerial *theSerial){ +#endif address = ptr; size = length; + _serial = theSerial; - + //dynamic creation of rx parsing buffer in RAM rx_buffer = (uint8_t*) malloc(size); } diff --git a/EasyTransfer/EasyTransfer.h b/EasyTransfer/EasyTransfer.h index 9562856..b75adb3 100644 --- a/EasyTransfer/EasyTransfer.h +++ b/EasyTransfer/EasyTransfer.h @@ -35,7 +35,7 @@ GNU General Public License for more details. #include "WProgram.h" #endif #include "HardwareSerial.h" -//#include +#include #include #include #include @@ -43,13 +43,27 @@ GNU General Public License for more details. class EasyTransfer { public: + +#if defined(SoftwareSerial_h) +void begin(uint8_t *, uint8_t, SoftSerial *theSerial); +#elif defined(__AVR_ATmega32U4__) +void begin(uint8_t *, uint8_t, Serial_ *theSerial); +#else void begin(uint8_t *, uint8_t, HardwareSerial *theSerial); -//void begin(uint8_t *, uint8_t, NewSoftSerial *theSerial); +#endif + void sendData(); boolean receiveData(); private: + +#if defined(SoftwareSerial_h) +SoftSerial *_serial; +#elif defined(__AVR_ATmega32U4__) +Serial_ *_serial; +#else HardwareSerial *_serial; -//NewSoftSerial *_serial; +#endif + uint8_t * address; //address of struct uint8_t size; //size of struct uint8_t * rx_buffer; //address for temporary storage and parsing buffer From 43e6e053356c96bff250f70e4ac69a6269226e23 Mon Sep 17 00:00:00 2001 From: "Michael P. Flaga" Date: Wed, 5 Feb 2014 14:32:27 -0500 Subject: [PATCH 2/2] Added support for Teensy Core --- EasyTransfer/EasyTransfer.cpp | 6 ++++-- EasyTransfer/EasyTransfer.h | 13 ++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/EasyTransfer/EasyTransfer.cpp b/EasyTransfer/EasyTransfer.cpp index 0480eb4..5ee9389 100644 --- a/EasyTransfer/EasyTransfer.cpp +++ b/EasyTransfer/EasyTransfer.cpp @@ -1,13 +1,15 @@ #include "EasyTransfer.h" -#if defined(SoftwareSerial_h) +#if defined(CORE_TEENSY) +void EasyTransfer::begin(uint8_t * ptr, uint8_t length, usb_serial_class *theSerial){ +#elif defined(SoftwareSerial_h) void EasyTransfer::begin(uint8_t * ptr, uint8_t length, SoftSerial *theSerial){ #elif defined(__AVR_ATmega32U4__) -//Captures address and size of struct void EasyTransfer::begin(uint8_t * ptr, uint8_t length, Serial_ *theSerial){ #else void EasyTransfer::begin(uint8_t * ptr, uint8_t length, HardwareSerial *theSerial){ #endif +//Captures address and size of struct address = ptr; size = length; diff --git a/EasyTransfer/EasyTransfer.h b/EasyTransfer/EasyTransfer.h index b75adb3..e2cb4c4 100644 --- a/EasyTransfer/EasyTransfer.h +++ b/EasyTransfer/EasyTransfer.h @@ -35,7 +35,9 @@ GNU General Public License for more details. #include "WProgram.h" #endif #include "HardwareSerial.h" -#include +#if !defined(CORE_TEENSY) +#include +#endif #include #include #include @@ -44,7 +46,10 @@ GNU General Public License for more details. class EasyTransfer { public: -#if defined(SoftwareSerial_h) + +#if defined(CORE_TEENSY) +void begin(uint8_t *, uint8_t, usb_serial_class *theSerial); +#elif defined(SoftwareSerial_h) void begin(uint8_t *, uint8_t, SoftSerial *theSerial); #elif defined(__AVR_ATmega32U4__) void begin(uint8_t *, uint8_t, Serial_ *theSerial); @@ -56,7 +61,9 @@ void sendData(); boolean receiveData(); private: -#if defined(SoftwareSerial_h) +#if defined(CORE_TEENSY) +usb_serial_class *_serial; +#elif defined(SoftwareSerial_h) SoftSerial *_serial; #elif defined(__AVR_ATmega32U4__) Serial_ *_serial;