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上でのみ、動作確認しています
XBusServo.h@18:75ddf12d93b6, 2014-11-05 (annotated)
- Committer:
- sawa
- Date:
- Wed Nov 05 03:12:27 2014 +0000
- Revision:
- 18:75ddf12d93b6
- Parent:
- 17:3ffb2e3e3bec
test publish
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sawa | 3:9a10ad81d04e | 1 | /** |
sawa | 3:9a10ad81d04e | 2 | * @file XBusServo.h |
sawa | 3:9a10ad81d04e | 3 | * @brief this header file will contain all required |
sawa | 13:5e2aa53353a8 | 4 | * definitions and basic utilities functions |
sawa | 13:5e2aa53353a8 | 5 | * for controling XBus servo. |
sawa | 3:9a10ad81d04e | 6 | * @author Zak Sawa |
sawa | 3:9a10ad81d04e | 7 | * @note Copyright (c) 2014-2014 JR PROPO |
sawa | 3:9a10ad81d04e | 8 | * @note Released under the MIT License: http://mbed.org/license/mit |
sawa | 0:381d475cfd6c | 9 | */ |
sawa | 13:5e2aa53353a8 | 10 | |
sawa | 0:381d475cfd6c | 11 | #ifndef XBusServo_h |
sawa | 0:381d475cfd6c | 12 | #define XBusServo_h |
sawa | 0:381d475cfd6c | 13 | |
sawa | 0:381d475cfd6c | 14 | #include "mbed.h" |
sawa | 18:75ddf12d93b6 | 15 | |
sawa | 0:381d475cfd6c | 16 | |
sawa | 5:7246a46379f7 | 17 | /// standard interval time for XBus servo |
sawa | 1:bd80d3e8f3a3 | 18 | #define kXBusStandardInterval 14 // mSec |
sawa | 0:381d475cfd6c | 19 | |
sawa | 5:7246a46379f7 | 20 | /// angle data for XBus servo |
sawa | 1:bd80d3e8f3a3 | 21 | #define kXbusServoMinimum 0x1249 // 900uSec -60 or -90 degree |
sawa | 1:bd80d3e8f3a3 | 22 | #define kXbusServoNeutral 0x7FFF // 1500uSec 0 degree |
sawa | 1:bd80d3e8f3a3 | 23 | #define kXbusServoMaximum 0xEDB6 // 2100uSec 60 or 90 degree |
sawa | 1:bd80d3e8f3a3 | 24 | |
sawa | 5:7246a46379f7 | 25 | /// maximum number of XBus servo |
sawa | 0:381d475cfd6c | 26 | #define kXBusMaxServoNum 50 |
sawa | 0:381d475cfd6c | 27 | |
sawa | 18:75ddf12d93b6 | 28 | /// convert ServoID & SubID to real Channel ID |
sawa | 18:75ddf12d93b6 | 29 | #define ChannelID(ServoID, SubID) ((ServoID & 0x3F) | ((SubID << 6) & 0xC0)) |
sawa | 18:75ddf12d93b6 | 30 | |
sawa | 17:3ffb2e3e3bec | 31 | |
sawa | 17:3ffb2e3e3bec | 32 | //! XBus error code |
sawa | 17:3ffb2e3e3bec | 33 | typedef enum { |
sawa | 17:3ffb2e3e3bec | 34 | kXBusError_NoError = 0x0000, |
sawa | 17:3ffb2e3e3bec | 35 | kXBusError_CRCError, |
sawa | 17:3ffb2e3e3bec | 36 | kXBusError_ServoNumOverflow, |
sawa | 17:3ffb2e3e3bec | 37 | kXBusError_ServoNumIsZero, |
sawa | 17:3ffb2e3e3bec | 38 | kXBusError_AddWithSameID, |
sawa | 17:3ffb2e3e3bec | 39 | kXBusError_IDNotFound, |
sawa | 17:3ffb2e3e3bec | 40 | kXBusError_Unsupported, |
sawa | 17:3ffb2e3e3bec | 41 | kXBusError_OnlyForTxOnlyMode, |
sawa | 17:3ffb2e3e3bec | 42 | kXBusError_OnlyForNormalMode, |
sawa | 17:3ffb2e3e3bec | 43 | kXBusError_MemoryFull, |
sawa | 17:3ffb2e3e3bec | 44 | |
sawa | 17:3ffb2e3e3bec | 45 | kXBusError_NumOfError, |
sawa | 17:3ffb2e3e3bec | 46 | } XBusError; |
sawa | 17:3ffb2e3e3bec | 47 | |
sawa | 17:3ffb2e3e3bec | 48 | //! XBus parameter index |
sawa | 17:3ffb2e3e3bec | 49 | typedef enum { |
sawa | 17:3ffb2e3e3bec | 50 | kParamIdx_Unused0 = 0x0000, |
sawa | 17:3ffb2e3e3bec | 51 | kParamIdx_AllData_wID = 0x0001, |
sawa | 17:3ffb2e3e3bec | 52 | kParamIdx_AllData_woID = 0x0002, |
sawa | 17:3ffb2e3e3bec | 53 | kParamIdx_ServoID = 0x0003, |
sawa | 17:3ffb2e3e3bec | 54 | kParamIdx_Reversed = 0x0004, |
sawa | 17:3ffb2e3e3bec | 55 | kParamIdx_NeutralOffset = 0x0005, |
sawa | 17:3ffb2e3e3bec | 56 | kParamIdx_TravelHigh = 0x0006, |
sawa | 17:3ffb2e3e3bec | 57 | kParamIdx_TravelLow = 0x0007, |
sawa | 17:3ffb2e3e3bec | 58 | kParamIdx_LimitHigh = 0x0008, |
sawa | 17:3ffb2e3e3bec | 59 | kParamIdx_LimitLow = 0x0009, |
sawa | 17:3ffb2e3e3bec | 60 | kParamIdx_PGainDiff = 0x000A, |
sawa | 17:3ffb2e3e3bec | 61 | kParamIdx_IGainDiff = 0x000B, |
sawa | 17:3ffb2e3e3bec | 62 | kParamIdx_DGainDiff = 0x000C, |
sawa | 17:3ffb2e3e3bec | 63 | kParamIdx_DeadBandDiff = 0x000D, |
sawa | 17:3ffb2e3e3bec | 64 | kParamIdx_PWOffsetDiff = 0x000E, |
sawa | 17:3ffb2e3e3bec | 65 | kParamIdx_AlarmLevel = 0x000F, |
sawa | 17:3ffb2e3e3bec | 66 | kParamIdx_AlarmDelay = 0x0010, |
sawa | 17:3ffb2e3e3bec | 67 | kParamIdx_Angle_180 = 0x0011, |
sawa | 17:3ffb2e3e3bec | 68 | kParamIdx_SlowStart = 0x0012, |
sawa | 17:3ffb2e3e3bec | 69 | kParamIdx_StopMode = 0x0013, |
sawa | 17:3ffb2e3e3bec | 70 | kParamIdx_SpeedLimit = 0x0014, |
sawa | 17:3ffb2e3e3bec | 71 | kParamIdx_MaxIntegerDiff = 0x0015, |
sawa | 17:3ffb2e3e3bec | 72 | } XBusParamIdx; |
sawa | 17:3ffb2e3e3bec | 73 | |
sawa | 17:3ffb2e3e3bec | 74 | //! XBus Get/Set/Status command order |
sawa | 0:381d475cfd6c | 75 | typedef enum { |
sawa | 0:381d475cfd6c | 76 | kXBusOrder_1_Mode = 0x01, |
sawa | 0:381d475cfd6c | 77 | kXBusOrder_1_ID = 0x03, |
sawa | 0:381d475cfd6c | 78 | kXBusOrder_2_Version = 0x04, // only for get |
sawa | 0:381d475cfd6c | 79 | kXBusOrder_2_Product = 0x05, // only for get |
sawa | 0:381d475cfd6c | 80 | kXBusOrder_1_Unsupported = 0x06, // only for status |
sawa | 0:381d475cfd6c | 81 | kXBusOrder_2_Reset = 0x07, // only for set |
sawa | 0:381d475cfd6c | 82 | kXBusOrder_2_ParamWrite = 0x08, // only for set |
sawa | 0:381d475cfd6c | 83 | |
sawa | 0:381d475cfd6c | 84 | kXBusOrder_2_Reverse = 0x10, |
sawa | 0:381d475cfd6c | 85 | kXBusOrder_2_Neutral = 0x11, |
sawa | 0:381d475cfd6c | 86 | kXBusOrder_2_H_Travel = 0x12, |
sawa | 0:381d475cfd6c | 87 | kXBusOrder_2_L_Travel = 0x13, |
sawa | 0:381d475cfd6c | 88 | kXBusOrder_2_H_Limit = 0x14, |
sawa | 0:381d475cfd6c | 89 | kXBusOrder_2_L_Limit = 0x15, |
sawa | 0:381d475cfd6c | 90 | kXBusOrder_1_P_Gain = 0x16, |
sawa | 0:381d475cfd6c | 91 | kXBusOrder_1_I_Gain = 0x17, |
sawa | 0:381d475cfd6c | 92 | kXBusOrder_1_D_Gain = 0x18, |
sawa | 0:381d475cfd6c | 93 | kXBusOrder_1_DeadBand = 0x19, |
sawa | 0:381d475cfd6c | 94 | kXBusOrder_2_PowerOffset = 0x1A, |
sawa | 0:381d475cfd6c | 95 | kXBusOrder_1_AlarmLevel = 0x1B, |
sawa | 0:381d475cfd6c | 96 | kXBusOrder_2_AlarmDelay = 0x1C, |
sawa | 0:381d475cfd6c | 97 | kXBusOrder_1_Angle_180 = 0x1D, |
sawa | 0:381d475cfd6c | 98 | kXBusOrder_1_SlowStart = 0x1E, |
sawa | 0:381d475cfd6c | 99 | kXBusOrder_1_StopMode = 0x1F, |
sawa | 0:381d475cfd6c | 100 | kXBusOrder_2_CurrentPos = 0x20, // only for get |
sawa | 0:381d475cfd6c | 101 | kXBusOrder_1_CurrentPow = 0x21, // only for get |
sawa | 0:381d475cfd6c | 102 | kXBusOrder_1_SpeedLimit = 0x22, |
sawa | 0:381d475cfd6c | 103 | kXBusOrder_2_MaxInteger = 0x23, |
sawa | 0:381d475cfd6c | 104 | } XBusOrder; |
sawa | 0:381d475cfd6c | 105 | |
sawa | 0:381d475cfd6c | 106 | |
sawa | 9:9248ea2cb4b5 | 107 | /** |
sawa | 13:5e2aa53353a8 | 108 | * @brief Library class for XBus servo |
sawa | 13:5e2aa53353a8 | 109 | * @note 2014/09/02 : move from Arduino lib by Sawa |
sawa | 13:5e2aa53353a8 | 110 | */ |
sawa | 17:3ffb2e3e3bec | 111 | class XBusServo |
sawa | 0:381d475cfd6c | 112 | { |
sawa | 0:381d475cfd6c | 113 | public: |
sawa | 17:3ffb2e3e3bec | 114 | |
sawa | 17:3ffb2e3e3bec | 115 | |
sawa | 13:5e2aa53353a8 | 116 | /** |
sawa | 13:5e2aa53353a8 | 117 | * @param tx pin name for tx |
sawa | 13:5e2aa53353a8 | 118 | * @param rx pin name for rx |
sawa | 17:3ffb2e3e3bec | 119 | * @param sw pin name for switch tx |
sawa | 13:5e2aa53353a8 | 120 | * @param maxServoNum max number of servo that you want to connect. |
sawa | 13:5e2aa53353a8 | 121 | * (limit 50) |
sawa | 13:5e2aa53353a8 | 122 | * this does just to resetve the buffer. you need to |
sawa | 13:5e2aa53353a8 | 123 | * add XBus servo at the beginning of your sketch |
sawa | 13:5e2aa53353a8 | 124 | * |
sawa | 13:5e2aa53353a8 | 125 | * @author 2014/09/02 : move from Arduino lib by Zak Sawa |
sawa | 13:5e2aa53353a8 | 126 | */ |
sawa | 17:3ffb2e3e3bec | 127 | XBusServo(PinName tx, PinName rx, PinName sw, uint8_t maxServoNum); |
sawa | 0:381d475cfd6c | 128 | |
sawa | 0:381d475cfd6c | 129 | public: |
sawa | 13:5e2aa53353a8 | 130 | /** |
sawa | 13:5e2aa53353a8 | 131 | * @return XBus error code |
sawa | 17:3ffb2e3e3bec | 132 | * @brief Start function to use XBus |
sawa | 17:3ffb2e3e3bec | 133 | * This should NOT be called on interrupt handler. |
sawa | 13:5e2aa53353a8 | 134 | * @author 2014/10/07 : Zak Sawa |
sawa | 13:5e2aa53353a8 | 135 | */ |
sawa | 1:bd80d3e8f3a3 | 136 | XBusError start(); |
sawa | 17:3ffb2e3e3bec | 137 | |
sawa | 13:5e2aa53353a8 | 138 | /** |
sawa | 17:3ffb2e3e3bec | 139 | * @brief Stop function to use XBus |
sawa | 17:3ffb2e3e3bec | 140 | * This should NOT be called on interrupt handler. |
sawa | 13:5e2aa53353a8 | 141 | * @author 2014/10/07 : Zak Sawa |
sawa | 13:5e2aa53353a8 | 142 | */ |
sawa | 1:bd80d3e8f3a3 | 143 | void stop(); |
sawa | 1:bd80d3e8f3a3 | 144 | |
sawa | 13:5e2aa53353a8 | 145 | /** |
sawa | 13:5e2aa53353a8 | 146 | * @return XBus error code |
sawa | 13:5e2aa53353a8 | 147 | * @param channelID channel ID of the XBus servo that you want to use |
sawa | 13:5e2aa53353a8 | 148 | * @param initValue initial value of this XBus servo |
sawa | 13:5e2aa53353a8 | 149 | * use kXbusServoNeutral for center of the XBus servo |
sawa | 17:3ffb2e3e3bec | 150 | * @brief Add new servo to the buffer on this library |
sawa | 17:3ffb2e3e3bec | 151 | * This should NOT be called on interrupt handler when you |
sawa | 17:3ffb2e3e3bec | 152 | * setup the XBus servo. |
sawa | 13:5e2aa53353a8 | 153 | * @author 2014/09/02 : move from Arduino lib by Zak Sawa |
sawa | 13:5e2aa53353a8 | 154 | */ |
sawa | 0:381d475cfd6c | 155 | XBusError addServo(uint8_t channelID, uint16_t initValue); |
sawa | 17:3ffb2e3e3bec | 156 | |
sawa | 13:5e2aa53353a8 | 157 | /** |
sawa | 13:5e2aa53353a8 | 158 | * @return XBus error code |
sawa | 13:5e2aa53353a8 | 159 | * @param channelID channel ID of the XBus servo that you want to remove |
sawa | 17:3ffb2e3e3bec | 160 | * @brief Remove the servo from the buffer on this library |
sawa | 17:3ffb2e3e3bec | 161 | * This should NOT be called on interrupt handler when you |
sawa | 17:3ffb2e3e3bec | 162 | * setup the XBus servo. |
sawa | 13:5e2aa53353a8 | 163 | * @author 2014/09/02 : move from Arduino lib by Zak Sawa |
sawa | 13:5e2aa53353a8 | 164 | */ |
sawa | 0:381d475cfd6c | 165 | XBusError removeServo(uint8_t channelID); |
sawa | 17:3ffb2e3e3bec | 166 | |
sawa | 13:5e2aa53353a8 | 167 | /** |
sawa | 13:5e2aa53353a8 | 168 | * @return XBus error code |
sawa | 13:5e2aa53353a8 | 169 | * @param channelID channel ID of the XBus servo that you want to set |
sawa | 13:5e2aa53353a8 | 170 | * @param value value of this XBus servo |
sawa | 13:5e2aa53353a8 | 171 | * use kXbusServoNeutral for center of the XBus servo |
sawa | 17:3ffb2e3e3bec | 172 | * @brief Set new value to the servo |
sawa | 17:3ffb2e3e3bec | 173 | * This should NOT be called on interrupt handler when you |
sawa | 17:3ffb2e3e3bec | 174 | * setup the XBus servo. |
sawa | 13:5e2aa53353a8 | 175 | * @author 2014/09/02 : move from Arduino lib by Zak Sawa |
sawa | 13:5e2aa53353a8 | 176 | */ |
sawa | 0:381d475cfd6c | 177 | XBusError setServo(uint8_t channelID, uint16_t value); |
sawa | 0:381d475cfd6c | 178 | |
sawa | 13:5e2aa53353a8 | 179 | /** |
sawa | 13:5e2aa53353a8 | 180 | * @brief This should be called on the timer handler when you |
sawa | 13:5e2aa53353a8 | 181 | * use the XBus servo. |
sawa | 13:5e2aa53353a8 | 182 | * @author 2014/09/02 : move from Arduino lib by Zak Sawa |
sawa | 13:5e2aa53353a8 | 183 | */ |
sawa | 0:381d475cfd6c | 184 | void sendChannelDataPacket(void); |
sawa | 0:381d475cfd6c | 185 | |
sawa | 13:5e2aa53353a8 | 186 | /** |
sawa | 13:5e2aa53353a8 | 187 | * @return XBus error code |
sawa | 13:5e2aa53353a8 | 188 | * @param oldChannelID channel IDof the XBus servo to change the ID |
sawa | 13:5e2aa53353a8 | 189 | * @param newChannelID new channel ID for the XBus servo |
sawa | 17:3ffb2e3e3bec | 190 | * @brief Set new channel ID to the XBus servo |
sawa | 17:3ffb2e3e3bec | 191 | * This should NOT be called on interrupt handler when you |
sawa | 17:3ffb2e3e3bec | 192 | * setup the XBus servo. |
sawa | 13:5e2aa53353a8 | 193 | * @author 2014/09/02 : move from Arduino lib by Zak Sawa |
sawa | 13:5e2aa53353a8 | 194 | */ |
sawa | 0:381d475cfd6c | 195 | XBusError setChannelID(uint8_t oldChannelID, uint8_t newChannelID); |
sawa | 17:3ffb2e3e3bec | 196 | |
sawa | 13:5e2aa53353a8 | 197 | /** |
sawa | 13:5e2aa53353a8 | 198 | * @return XBus error code |
sawa | 13:5e2aa53353a8 | 199 | * @param channelID channel ID of the XBus servo that you want to set to |
sawa | 13:5e2aa53353a8 | 200 | * @param order the order that you want |
sawa | 13:5e2aa53353a8 | 201 | * @param value the value that you want to set and return current value |
sawa | 17:3ffb2e3e3bec | 202 | * @brief Send set command to the XBus servo |
sawa | 17:3ffb2e3e3bec | 203 | * This should NOT be called on interrupt handler when you |
sawa | 17:3ffb2e3e3bec | 204 | * setup the XBus servo. |
sawa | 13:5e2aa53353a8 | 205 | * @author 2014/09/02 : move from Arduino lib by Zak Sawa |
sawa | 13:5e2aa53353a8 | 206 | */ |
sawa | 0:381d475cfd6c | 207 | XBusError setCommand(uint8_t channelID, uint8_t order, int16_t* value); |
sawa | 17:3ffb2e3e3bec | 208 | |
sawa | 13:5e2aa53353a8 | 209 | /** |
sawa | 13:5e2aa53353a8 | 210 | * @return XBus error code |
sawa | 13:5e2aa53353a8 | 211 | * @param channelID channel ID of the XBus servo that you want to get from |
sawa | 13:5e2aa53353a8 | 212 | * @param order the order that you want |
sawa | 13:5e2aa53353a8 | 213 | * @param value the value that you want to get from |
sawa | 17:3ffb2e3e3bec | 214 | * @brief Send get command to the XBus servo |
sawa | 17:3ffb2e3e3bec | 215 | * This should NOT be called on interrupt handler when you |
sawa | 17:3ffb2e3e3bec | 216 | * setup the XBus servo. |
sawa | 13:5e2aa53353a8 | 217 | * @author 2014/09/02 : move from Arduino lib by Zak Sawa |
sawa | 13:5e2aa53353a8 | 218 | */ |
sawa | 0:381d475cfd6c | 219 | XBusError getCommand(uint8_t channelID, uint8_t order, int16_t* value); |
sawa | 0:381d475cfd6c | 220 | |
sawa | 13:5e2aa53353a8 | 221 | /** |
sawa | 13:5e2aa53353a8 | 222 | * @return XBus error code |
sawa | 13:5e2aa53353a8 | 223 | * @param newChannelID new channel ID for the XBus servo |
sawa | 17:3ffb2e3e3bec | 224 | * @brief Set new channel ID to the XBus servo |
sawa | 17:3ffb2e3e3bec | 225 | * This should NOT be called on interrupt handler when you |
sawa | 17:3ffb2e3e3bec | 226 | * setup the XBus servo. |
sawa | 14:8f44990ecb74 | 227 | * @note this is only for TX only mode |
sawa | 13:5e2aa53353a8 | 228 | * @author 2014/09/02 : move from Arduino lib by Zak Sawa |
sawa | 13:5e2aa53353a8 | 229 | */ |
sawa | 0:381d475cfd6c | 230 | XBusError setChannelID(uint8_t newChannelID); |
sawa | 17:3ffb2e3e3bec | 231 | |
sawa | 13:5e2aa53353a8 | 232 | /** |
sawa | 13:5e2aa53353a8 | 233 | * @return XBus error code |
sawa | 13:5e2aa53353a8 | 234 | * @param order the order that you want |
sawa | 13:5e2aa53353a8 | 235 | * @param value the value that you want to set and return current value |
sawa | 17:3ffb2e3e3bec | 236 | * @brief Send set command to the XBus servo |
sawa | 17:3ffb2e3e3bec | 237 | * This should NOT be called on interrupt handler when you |
sawa | 17:3ffb2e3e3bec | 238 | * setup the XBus servo. |
sawa | 14:8f44990ecb74 | 239 | * @note this is only for TX only mode |
sawa | 13:5e2aa53353a8 | 240 | * @author 2014/09/02 : move from Arduino lib by Zak Sawa |
sawa | 13:5e2aa53353a8 | 241 | */ |
sawa | 0:381d475cfd6c | 242 | XBusError setCommand(uint8_t order, int16_t* value); |
sawa | 0:381d475cfd6c | 243 | |
sawa | 0:381d475cfd6c | 244 | |
sawa | 0:381d475cfd6c | 245 | private: |
sawa | 17:3ffb2e3e3bec | 246 | #define kRecieveBufferSize 32 |
sawa | 1:bd80d3e8f3a3 | 247 | |
sawa | 1:bd80d3e8f3a3 | 248 | RawSerial XBusPort; |
sawa | 17:3ffb2e3e3bec | 249 | DigitalOut TxSwitch; |
sawa | 17:3ffb2e3e3bec | 250 | Timeout TxSwitchTimer; |
sawa | 1:bd80d3e8f3a3 | 251 | |
sawa | 0:381d475cfd6c | 252 | uint8_t txOnly; // 1 for TX only mode |
sawa | 0:381d475cfd6c | 253 | PinName txPin; // |
sawa | 0:381d475cfd6c | 254 | uint8_t numOfServo; // number of servos |
sawa | 0:381d475cfd6c | 255 | uint8_t maxServo; // max number of servos |
sawa | 0:381d475cfd6c | 256 | uint8_t* chPacketBuffer; // channel data packet buffer |
sawa | 0:381d475cfd6c | 257 | uint8_t* sendBuffer; // serial send buffer |
sawa | 17:3ffb2e3e3bec | 258 | volatile uint8_t* sendBufferPointer; |
sawa | 17:3ffb2e3e3bec | 259 | volatile uint8_t sendLength; |
sawa | 18:75ddf12d93b6 | 260 | volatile uint8_t recieveBuffer[kRecieveBufferSize]; // serial recieve buffer |
sawa | 17:3ffb2e3e3bec | 261 | volatile int8_t recieveBufferPointer; |
sawa | 0:381d475cfd6c | 262 | uint8_t dirty; // |
sawa | 17:3ffb2e3e3bec | 263 | volatile uint8_t serialCommandBusy; // |
sawa | 0:381d475cfd6c | 264 | volatile uint8_t modifyServosNow; // |
sawa | 17:3ffb2e3e3bec | 265 | volatile uint8_t need2ReadData; |
sawa | 0:381d475cfd6c | 266 | |
sawa | 0:381d475cfd6c | 267 | uint8_t crc_table(uint8_t data, uint8_t crc); |
sawa | 0:381d475cfd6c | 268 | uint8_t crc8(uint8_t* buffer, uint8_t length); |
sawa | 13:5e2aa53353a8 | 269 | /** |
sawa | 13:5e2aa53353a8 | 270 | * @return data size for this order |
sawa | 13:5e2aa53353a8 | 271 | * @param order the order that you want to know |
sawa | 17:3ffb2e3e3bec | 272 | * @brief Get the data size of this order |
sawa | 13:5e2aa53353a8 | 273 | * @author 2014/09/02 : move from Arduino lib by Zak Sawa |
sawa | 13:5e2aa53353a8 | 274 | */ |
sawa | 0:381d475cfd6c | 275 | uint8_t getDataSize(uint8_t order); |
sawa | 0:381d475cfd6c | 276 | |
sawa | 13:5e2aa53353a8 | 277 | /** |
sawa | 13:5e2aa53353a8 | 278 | * @param buffer data buffer to send |
sawa | 13:5e2aa53353a8 | 279 | * @param length data length on the buffer |
sawa | 17:3ffb2e3e3bec | 280 | * @brief Start to send all packet data |
sawa | 13:5e2aa53353a8 | 281 | * @author 2014/09/30 : Zak Sawa |
sawa | 13:5e2aa53353a8 | 282 | */ |
sawa | 0:381d475cfd6c | 283 | void write(uint8_t* buffer, uint8_t length); |
sawa | 17:3ffb2e3e3bec | 284 | |
sawa | 13:5e2aa53353a8 | 285 | /** |
sawa | 17:3ffb2e3e3bec | 286 | * @brief Wait to send all packet data |
sawa | 13:5e2aa53353a8 | 287 | * @author 2014/09/30 : Zak Sawa |
sawa | 13:5e2aa53353a8 | 288 | */ |
sawa | 0:381d475cfd6c | 289 | void flush(void); |
sawa | 17:3ffb2e3e3bec | 290 | |
sawa | 13:5e2aa53353a8 | 291 | /** |
sawa | 13:5e2aa53353a8 | 292 | * @brief handler for Tx buffer empty |
sawa | 13:5e2aa53353a8 | 293 | * @author 2014/09/30 : Zak Sawa |
sawa | 13:5e2aa53353a8 | 294 | */ |
sawa | 17:3ffb2e3e3bec | 295 | // void TxIrqHandler(MODSERIAL_IRQ_INFO *q); |
sawa | 0:381d475cfd6c | 296 | void TxIrqHandler(void); |
sawa | 17:3ffb2e3e3bec | 297 | |
sawa | 13:5e2aa53353a8 | 298 | /** |
sawa | 13:5e2aa53353a8 | 299 | * @brief handler for Rx buffer full |
sawa | 13:5e2aa53353a8 | 300 | * @author 2014/09/30 : Zak Sawa |
sawa | 13:5e2aa53353a8 | 301 | */ |
sawa | 17:3ffb2e3e3bec | 302 | // void RxIrqHandler(MODSERIAL_IRQ_INFO *q); |
sawa | 0:381d475cfd6c | 303 | void RxIrqHandler(void); |
sawa | 0:381d475cfd6c | 304 | |
sawa | 13:5e2aa53353a8 | 305 | /** |
sawa | 17:3ffb2e3e3bec | 306 | * @brief handler for Tx switch |
sawa | 17:3ffb2e3e3bec | 307 | * @author 2014/10/29 : Zak Sawa |
sawa | 17:3ffb2e3e3bec | 308 | */ |
sawa | 17:3ffb2e3e3bec | 309 | void TxSwitchHandler(void); |
sawa | 17:3ffb2e3e3bec | 310 | |
sawa | 17:3ffb2e3e3bec | 311 | /** |
sawa | 13:5e2aa53353a8 | 312 | * @param command The commnad that you want to send |
sawa | 13:5e2aa53353a8 | 313 | * @param channelID The channel ID of the XBus servo that you want to set up |
sawa | 13:5e2aa53353a8 | 314 | * @param order The order that you want to set up |
sawa | 13:5e2aa53353a8 | 315 | * @param value The value that you want to set / get |
sawa | 13:5e2aa53353a8 | 316 | * @param valueSize The value size. 1 byte(char) or 2 byte(int) |
sawa | 17:3ffb2e3e3bec | 317 | * @brief This should NOT be called on interrupt handler when you |
sawa | 13:5e2aa53353a8 | 318 | * setup the XBus servo. |
sawa | 13:5e2aa53353a8 | 319 | * @author 2014/09/02 : move from Arduino lib by Zak Sawa |
sawa | 13:5e2aa53353a8 | 320 | */ |
sawa | 0:381d475cfd6c | 321 | XBusError sendCommandDataPacket(uint8_t command, uint8_t channelID, uint8_t order, int16_t* value, uint8_t valueSize); |
sawa | 0:381d475cfd6c | 322 | }; |
sawa | 0:381d475cfd6c | 323 | |
sawa | 0:381d475cfd6c | 324 | |
sawa | 0:381d475cfd6c | 325 | #endif // of XBusServo_h |
sawa | 0:381d475cfd6c | 326 |