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:
13:5e2aa53353a8
Parent:
12:0e9d5941fc22
Child:
14:8f44990ecb74
--- a/XBusServo.h	Wed Oct 08 06:08:44 2014 +0000
+++ b/XBusServo.h	Wed Oct 08 07:18:27 2014 +0000
@@ -1,12 +1,13 @@
 /**
  *  @file   XBusServo.h
  *  @brief  this header file will contain all required
- *          definitions and basic utilities functions.
+ *          definitions and basic utilities functions
+ *          for controling XBus servo.
  *  @author Zak Sawa
  *  @note   Copyright (c) 2014-2014 JR PROPO
  *  @note   Released under the MIT License: http://mbed.org/license/mit
  */
- 
+
 #ifndef XBusServo_h
 #define XBusServo_h
 
@@ -100,48 +101,113 @@
 
 
 /**
-    @brief              Library class for XBus servo
-    @note               2014/09/02 : move from Arduino lib by Sawa
-*/
+ *   @brief              Library class for XBus servo
+ *   @note               2014/09/02 : move from Arduino lib by Sawa
+ */
 class XBusServo // : private RawSerial
 {
 public:
-/**
-    @param tx           pin name for tx
-    @param rx           pin name for rx
-    @param maxServoNum  max number of servo that you want to connect.
-                        (limit 50)
-                        this does just to resetve the buffer.  you need to
-                        add XBus servo at the beginning of your sketch
-
-    @note               2014/09/02 : move from Arduino lib by Sawa
-*/
+    /**
+     *  @param tx           pin name for tx
+     *  @param rx           pin name for rx
+     *  @param maxServoNum  max number of servo that you want to connect.
+     *                      (limit 50)
+     *                      this does just to resetve the buffer.  you need to
+     *                      add XBus servo at the beginning of your sketch
+     *
+     *  @author             2014/09/02 : move from Arduino lib by Zak Sawa
+     */
     XBusServo(PinName tx, PinName rx, uint8_t maxServoNum);
 
 public:
-/**
-    @return             XBus error code
-    @brief              start function to use XBus
-    @note               2014/09/02 : move from Arduino lib by Sawa
-*/
+    /**
+     *  @return             XBus error code
+     *  @brief              start function to use XBus
+     *  @author             2014/10/07 : Zak Sawa
+     */
     XBusError       start();
-/**
-    @brief              stop function to use XBus
-    @note               2014/09/02 : move from Arduino lib by Sawa
-*/
+    /**
+     *  @brief              stop function to use XBus
+     *  @author             2014/10/07 : Zak Sawa
+     */
     void            stop();
 
+    /**
+     *  @return             XBus error code
+     *  @param channelID    channel ID of the XBus servo that you want to use
+     *  @param initValue    initial value of this XBus servo
+     *                      use kXbusServoNeutral for center of the XBus servo
+     *  @brief              add new servo to the buffer on this library
+     *  @author             2014/09/02 : move from Arduino lib by Zak Sawa
+     */
     XBusError       addServo(uint8_t channelID, uint16_t initValue);
+    /**
+     *  @return             XBus error code
+     *  @param channelID    channel ID of the XBus servo that you want to remove
+     *  @brief              remove the servo from the buffer on this library
+     *  @author             2014/09/02 : move from Arduino lib by Zak Sawa
+     */
     XBusError       removeServo(uint8_t channelID);
+    /**
+     *  @return             XBus error code
+     *  @param channelID    channel ID of the XBus servo that you want to set
+     *  @param value        value of this XBus servo
+     *                      use kXbusServoNeutral for center of the XBus servo
+     *  @brief              set new value to the servo
+     *  @author             2014/09/02 : move from Arduino lib by Zak Sawa
+     */
     XBusError       setServo(uint8_t channelID, uint16_t value);
 
+    /**
+     *  @brief              This should be called on the timer handler when you
+     *                      use the XBus servo.
+     *  @author             2014/09/02 : move from Arduino lib by Zak Sawa
+     */
     void            sendChannelDataPacket(void);
 
+    /**
+     *  @return             XBus error code
+     *  @param oldChannelID channel IDof the XBus servo to change the ID
+     *  @param newChannelID new channel ID for the XBus servo
+     *  @brief              set new channel ID to the XBus servo
+     *  @author             2014/09/02 : move from Arduino lib by Zak Sawa
+     */
     XBusError       setChannelID(uint8_t oldChannelID, uint8_t newChannelID);
+    /**
+     *  @return             XBus error code
+     *  @param channelID    channel ID of the XBus servo that you want to set to
+     *  @param order        the order that you want
+     *  @param value        the value that you want to set and return current value
+     *  @brief              send set command to the XBus servo
+     *  @author             2014/09/02 : move from Arduino lib by Zak Sawa
+     */
     XBusError       setCommand(uint8_t channelID, uint8_t order, int16_t* value);
+    /**
+     *  @return             XBus error code
+     *  @param channelID    channel ID of the XBus servo that you want to get from
+     *  @param order        the order that you want
+     *  @param value        the value that you want to get from
+     *  @brief              send get command to the XBus servo
+     *  @author             2014/09/02 : move from Arduino lib by Zak Sawa
+     */
     XBusError       getCommand(uint8_t channelID, uint8_t order, int16_t* value);
 
+    /**
+     *  @return             XBus error code
+     *  @param newChannelID new channel ID for the XBus servo
+     *  @brief              set new channel ID to the XBus servo
+     *                      this is only for TX only mode
+     *  @author             2014/09/02 : move from Arduino lib by Zak Sawa
+     */
     XBusError       setChannelID(uint8_t newChannelID);
+    /**
+     *  @return             XBus error code
+     *  @param order        the order that you want
+     *  @param value        the value that you want to set and return current value
+     *  @brief              send set command to the XBus servo
+     *                      this is only for TX only mode
+     *  @author             2014/09/02 : move from Arduino lib by Zak Sawa
+     */
     XBusError       setCommand(uint8_t order, int16_t* value);
 
 
@@ -166,13 +232,47 @@
 
     uint8_t             crc_table(uint8_t data, uint8_t crc);
     uint8_t             crc8(uint8_t* buffer, uint8_t length);
+    /**
+     *  @return             data size for this order
+     *  @param order        the order that you want to know
+     *  @brief              get the data size of this order
+     *  @author             2014/09/02 : move from Arduino lib by Zak Sawa
+     */
     uint8_t             getDataSize(uint8_t    order);
 
+    /**
+     *  @param buffer       data buffer to send
+     *  @param length       data length on the buffer
+     *  @brief              start to send all packet data
+     *  @author             2014/09/30 : Zak Sawa
+     */
     void                write(uint8_t* buffer, uint8_t length);
+    /**
+     *  @brief              wait to send all packet data
+     *  @author             2014/09/30 : Zak Sawa
+     */
     void                flush(void);
+    /**
+     *  @brief              handler for Tx buffer empty
+     *  @author             2014/09/30 : Zak Sawa
+     */
     void                TxIrqHandler(void);
+    /**
+     *  @brief              handler for Rx buffer full
+     *  @author             2014/09/30 : Zak Sawa
+     */
     void                RxIrqHandler(void);
 
+    /**
+     *  @param command      The commnad that you want to send
+     *  @param channelID    The channel ID of the XBus servo that you want to set up
+     *  @param order        The order that you want to set up
+     *  @param value        The value that you want to set / get
+     *  @param valueSize    The value size.  1 byte(char) or 2 byte(int)
+     *  @brief              This should NOT be called on the timer handler when you
+     *                      setup the XBus servo.
+     *  @author             2014/09/02 : move from Arduino lib by Zak Sawa
+     */
     XBusError           sendCommandDataPacket(uint8_t command, uint8_t channelID, uint8_t order, int16_t* value, uint8_t valueSize);
 };