first_library

Dependents:   2019_tourobo_upper minirobo_upper_reserve minirobo_under_reserve serial_RTX_NUCLEA

Revision:
0:03e99bd9339e
diff -r 000000000000 -r 03e99bd9339e Sabertooth_Serial.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Sabertooth_Serial.cpp	Mon Feb 04 04:30:22 2019 +0000
@@ -0,0 +1,12 @@
+#include "Sabertooth_Serial.h"
+
+SaberSerial::SaberSerial(int baudrate, PinName tx, PinName rx) : _Sabertooth(tx, rx){
+    _Sabertooth.baud(baudrate);
+}
+
+void SaberSerial::Serial(int address, int direction, int cmd){
+    _Sabertooth.putc(address);
+    _Sabertooth.putc(direction); 
+    _Sabertooth.putc(abs(cmd));
+    _Sabertooth.putc((address + direction + abs(cmd)) & 0b01111111);
+}
\ No newline at end of file