Example use of I2CTransaction class. In this example, the master mbed is talking to 3 legs of the SIPPC3B robot.

Revision:
6:a52ded837184
Parent:
5:86f1cd6657de
Child:
7:c164b4869f74
--- a/LegInterface.h	Fri Jun 20 06:10:34 2014 +0000
+++ b/LegInterface.h	Tue Aug 05 21:53:59 2014 +0000
@@ -16,16 +16,16 @@
 
     // An array of I2C addresses indexable by enum Leg
     static const int LegAddress[];
-    
+
     // Encoder to wheel
     static const float TICKS_PER_METER = 52633.97;
-    
+
     // Angle between front legs
     static const float FRONT_LEG_ANGLE = 130;  // Degrees
-    
+
     // Distance from center of robot to wheel
     static const float ROBOT_RADIUS = 0.4702;  // m
-    
+
     // Number of A2D ticks per meter.  TODO: is 4096 right?
     static const float LIFT_TICKS_PER_METER = 4096 / 0.1;
 
@@ -37,9 +37,12 @@
     bool sendEstop(bool estop);
     bool queryStateInitiate();
     bool queryStateCompleted();
+    bool queryStateSuccess();
+    bool queryEstopCompleted();
+    bool queryEstopSuccess();
     bool queryStateWaitForCompletion(int timeout = 1000);
     bool queryStateCopy(LegState_t legState[NUM_LEGS]);
-    bool queryStateCopy(float liftPosition[NUM_LEGS], float liftVelocity[NUM_LEGS], float wheelPosition[NUM_LEGS], float wheelVelocity[NUM_LEGS]);
+    bool queryStateCopy(float liftPosition[NUM_LEGS], float liftVelocity[NUM_LEGS], float wheelPosition[NUM_LEGS], float wheelVelocity[NUM_LEGS], bool cliff[NUM_LEGS], bool limit[NUM_LEGS], bool estop[NUM_LEGS], uint8_t magic[NUM_LEGS]);
     void displayLegState(LegState_t *legState);
     void queryStateTest(Serial *pc);
     bool queryLegParams(Leg leg, LegControlParams_t *liftParams, LegControlParams_t *wheelParams);
@@ -47,10 +50,16 @@
     bool setLegParams(Leg leg, LegControlParams_t *liftParams, LegControlParams_t *wheelParams);
     bool setLegGoal(int32_t liftPos[NUM_LEGS], int32_t wheelVel[NUM_LEGS]);
     bool setLegGoal(float liftPos[NUM_LEGS], float wheelVel[NUM_LEGS]);
+    bool getLegGoalCompleted();
+    bool getLegGoalSuccess();
     void displayStatus();
+    //bool getLegGoalStatus();
+    void clearQueryTransactions();
+    void clearSetGoalTransactions();
     static void reset();
     static void resetBus();
     static void cycleBus();
+    static void initI2C(PinName sda, PinName scl);
 
 private:
     I2CTransaction *transactionEstop[NUM_LEGS];
@@ -71,7 +80,7 @@
     I2CTransaction *transactionSetWheelParams[NUM_LEGS];
     LegPacket_t legPacketSetLiftParams;
     LegPacket_t legPacketSetWheelParams;
-    
+
     I2CTransaction *transactionSetGoal[NUM_LEGS];
     LegPacket_t legPacketSetGoal[NUM_LEGS];
     Serial *pc;