summaryrefslogtreecommitdiff
path: root/arduino_libs_0022/SerialManager/.svn/text-base/SerialManager.h.svn-base
diff options
context:
space:
mode:
Diffstat (limited to 'arduino_libs_0022/SerialManager/.svn/text-base/SerialManager.h.svn-base')
-rwxr-xr-xarduino_libs_0022/SerialManager/.svn/text-base/SerialManager.h.svn-base63
1 files changed, 63 insertions, 0 deletions
diff --git a/arduino_libs_0022/SerialManager/.svn/text-base/SerialManager.h.svn-base b/arduino_libs_0022/SerialManager/.svn/text-base/SerialManager.h.svn-base
new file mode 100755
index 0000000..dcbdba6
--- /dev/null
+++ b/arduino_libs_0022/SerialManager/.svn/text-base/SerialManager.h.svn-base
@@ -0,0 +1,63 @@
+/*
+ SerialManager.h - Library for doing packetized serial comm with Arduinos.
+ Created by Sigurdur Orn, May 23, 2010.
+ */
+#ifndef SerialManager_h
+#define SerialManager_h
+
+#include "ByteBuffer.h"
+#include "WProgram.h"
+
+typedef void (*voidFuncPtr)(ByteBuffer*);
+
+#if defined(__AVR_ATmega8__)
+ #define UCSRA UCSRA
+ #define UDRE UDRE
+#else
+ #define UCSRA UCSR0A
+ #define UDRE UDRE0
+#endif
+
+#if defined(__AVR_ATmega1280__)
+ #define UCSRA1 UCSR1A
+ #define UDRE1 UDRE1
+ #define UCSRA2 UCSR2A
+ #define UDRE2 UDRE2
+ #define UCSRA3 UCSR3A
+ #define UDRE3 UDRE3
+#endif
+
+
+class SerialManager
+{
+public:
+ SerialManager(unsigned int in_buf_size, unsigned int out_buf_size);
+ void init(int serial_port, int baud_rate);
+ void setPacketHandler(void (*rx_func)(ByteBuffer*));
+
+ void update();
+ bool isBusySending();
+
+ int sendSerialByte(byte b);
+ int sendSerialPacket(ByteBuffer* packet);
+ int sendRawSerial(ByteBuffer* packet);
+
+private:
+ void handleIncomingByte(byte incoming);
+ void handlePacketDefault(ByteBuffer* packet);
+
+ voidFuncPtr handlePacketFunction;
+
+ byte _serial_port;
+ ByteBuffer* incoming_buffer;
+ ByteBuffer* outgoing_buffer;
+ ByteBuffer* temp_buffer;
+ byte serial_in_checksum;
+ byte byte1;
+ byte byte2;
+ byte byte3;
+ byte byte4;
+};
+
+#endif
+