Control the Pololu SMC02B

Files at this revision

API Documentation at this revision

Comitter:
goncaloc
Date:
Mon Oct 11 20:25:57 2010 +0000
Parent:
3:8595605248a3
Commit message:
0v5

Changed in this revision

SMC02B.cpp Show annotated file Show diff for this revision Revisions of this file
SMC02B.h Show annotated file Show diff for this revision Revisions of this file
diff -r 8595605248a3 -r 420e977e37b6 SMC02B.cpp
--- a/SMC02B.cpp	Mon Oct 11 18:58:40 2010 +0000
+++ b/SMC02B.cpp	Mon Oct 11 20:25:57 2010 +0000
@@ -3,7 +3,7 @@
 */
 #include "SMC02B.h" 
  
-    SMC02B::SMC02B(PinName tx, PinName rx, PinName pin) : _rst(pin)
+    SMC02B::SMC02B(PinName tx, PinName rx, PinName rst) : _rst(rst)
     {
         _SMC02B = new Serial( tx, rx);
         _rst = 1;
diff -r 8595605248a3 -r 420e977e37b6 SMC02B.h
--- a/SMC02B.h	Mon Oct 11 18:58:40 2010 +0000
+++ b/SMC02B.h	Mon Oct 11 20:25:57 2010 +0000
@@ -3,7 +3,7 @@
  * 
  * @section LICENSE
  *
- * Copyright (c) 2010 ARM Limited
+ * Copyright (c) 2010
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -30,6 +30,7 @@
  * Datasheet:
  *
  * http://www.pololu.com/file/0J36/smc02b_guide.pdf
+ *
  */
  
 #ifndef SMC02B_H
@@ -55,17 +56,66 @@
 #define SMC02B_MOTOR2_NUMBER    0x00
 
 /**
+*
 * Pololu Micro Dual Serial Motor Controller.
+*
 */
 
-class SMC02B
-{
+class SMC02B {
+
 public:
-    SMC02B(PinName tx, PinName rx, PinName pin);
+
+    /**
+     * Constructor.
+     *
+     * @param tx mbed pin to use for TX line of Serial.
+     * @param rx mbed pin to use for RX line of Serial.
+     * @param rst mbed pin to use for RESET.
+     */
+    SMC02B(PinName tx, PinName rx, PinName rst);
+    
+    /**
+     * Reset SMC02B.
+     *
+     */
     void SMC02B_RST(void);
+
+    /**
+     * Set Motor.
+     *
+     * @param motor - Motor to be controlled.
+     * @param direction - Motor Direction.
+     *                    0 - Reverse
+     *                    1 - Forward
+     * @param speed - Motor Speed.
+     *                    0 - 127 ( 0x7F )
+     */
     void SMC02B_MOTOR_SET( char motor, char direction, char speed );
+
+    /**
+     * Set Motor to Brake.
+     *
+     * @param motor - Motor to be controlled.
+     */
     void SMC02B_MOTOR_BRAKE( char motor );
+
+    /**
+     * Set Motor to idle.
+     *
+     * @param motor - Motor to be controlled.
+     */
     void SMC02B_MOTOR_COAST( char motor );
+
+    /**
+     * Configure SMC02B.
+     *
+     * @param mode - Set mode 1 or 2 motor mode.
+     *              0 - 2 motors
+     *              1 - 1 motor
+     * @param motor - Motor number.
+     *
+     *  Allways reset SMC02B after a config
+     */
     void SMC02B_CONFIG( char mode, char motor );
 
 private: