Library for XBus servo (under construction)

Dependents:   mbed_XBus_Test mbed_XBus_MotionTest XBusServoTest ControlYokutan2017_2 ... more

It's pre-opened page. it's still a little bit unstable to use command packet but mostly work. Tested only on KL25Z

暫定版ページです。 まだコマンドパケット使用時に時々不安定になりますが、概ね動作しています。 KL25Z上でのみ、動作確認しています

Revision:
1:bd80d3e8f3a3
Parent:
0:381d475cfd6c
Child:
2:4aca5ffce457
--- a/XBusServo.h	Thu Oct 02 08:46:53 2014 +0000
+++ b/XBusServo.h	Wed Oct 08 01:59:16 2014 +0000
@@ -2,7 +2,9 @@
  *
  * for mbed
  *
- * Copyright (c) 2013-2014 JR PROPO
+ * Copyright (c) 2014-2014 JR PROPO
+ * Released under the MIT License: http://mbed.org/license/mit
+ *
  * by Zak Sawa
  */
 
@@ -10,11 +12,16 @@
 #define XBusServo_h
 
 #include "mbed.h"
-#include "gpio_api.h"
 
+// standard interval time for XBus servo
+#define kXBusStandardInterval       14              // mSec
 
-#define kXBusInterval               14              // mSec
-#define kXbusServoNeutral           0x7FFF          // 1500uSec
+// angle data for XBus servo
+#define kXbusServoMinimum           0x1249          // 900uSec      -60 or -90 degree
+#define kXbusServoNeutral           0x7FFF          // 1500uSec     0 degree
+#define kXbusServoMaximum           0xEDB6          // 2100uSec     60 or 90 degree
+
+// maximum number of XBus servo
 #define kXBusMaxServoNum            50
 
 // XBus Get/Set/Status command order
@@ -94,13 +101,15 @@
 
 
 
-class XBusServo : private RawSerial             //, private DigitalInOut
+class XBusServo // : private RawSerial             //, private DigitalInOut
 {
 public:
     XBusServo(PinName tx, PinName rx, uint8_t maxServoNum);
-    virtual ~XBusServo();
 
 public:
+    XBusError       start();
+    void            stop();
+
     XBusError       addServo(uint8_t channelID, uint16_t initValue);
     XBusError       removeServo(uint8_t channelID);
     XBusError       setServo(uint8_t channelID, uint16_t value);
@@ -116,8 +125,10 @@
 
 
 private:
-    #define         kRecieveBufferSize          64
-    
+#define         kRecieveBufferSize          64
+
+    RawSerial           XBusPort;
+
     uint8_t             txOnly;          // 1 for TX only mode
     PinName             txPin;           //
     uint8_t             numOfServo;      // number of servos