Control up to 4 DC Motors from a serial port

Dependencies:   mbed

Committer:
jm
Date:
Sat Feb 12 16:39:20 2011 +0000
Revision:
0:dedab08b24ea
jmMotor Command Line Interface Module

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jm 0:dedab08b24ea 1 /*************************************************************************
jm 0:dedab08b24ea 2 * @file jmMotor.h
jm 0:dedab08b24ea 3 * @brief Control motor drive, direction and repetition on mbed DIP5 to 30.
jm 0:dedab08b24ea 4 * Up to 4 motors can be controlled at the same time.
jm 0:dedab08b24ea 5 *
jm 0:dedab08b24ea 6 * @version 1.0
jm 0:dedab08b24ea 7 * @date Feb 12, 2011
jm 0:dedab08b24ea 8 */
jm 0:dedab08b24ea 9
jm 0:dedab08b24ea 10 /*
jm 0:dedab08b24ea 11 * Module Command Line Interface
jm 0:dedab08b24ea 12 Format: command name (arg info)min..max values [optional argument]
jm 0:dedab08b24ea 13
jm 0:dedab08b24ea 14 motor (Motor ID)0..3 (Direction Pin)0..432 (Drive Pin)0..432 (Rotation cw/ccw)0..1 (tOn)0..255 (tOff)0..255 (Cycles)[1..65535]
jm 0:dedab08b24ea 15
jm 0:dedab08b24ea 16 * Module Events
jm 0:dedab08b24ea 17 On terminating cycles, send Message: GPPMT id dirPin drivePinB tOn tOff status
jm 0:dedab08b24ea 18
jm 0:dedab08b24ea 19 * Module Feedback and Help messages may be enabled/disabled by Command Lines.
jm 0:dedab08b24ea 20 feedback (enable/disable)0..1
jm 0:dedab08b24ea 21 help (enable/disable)0..1
jm 0:dedab08b24ea 22 */
jm 0:dedab08b24ea 23
jm 0:dedab08b24ea 24 #ifndef Motordef
jm 0:dedab08b24ea 25 #define Motordef 1
jm 0:dedab08b24ea 26
jm 0:dedab08b24ea 27 #define motorQty 4 // max number of motor
jm 0:dedab08b24ea 28
jm 0:dedab08b24ea 29 #include "LPC17xx.h"
jm 0:dedab08b24ea 30
jm 0:dedab08b24ea 31 // Module Data Structure
jm 0:dedab08b24ea 32 extern struct StructMotor{
jm 0:dedab08b24ea 33 uint8_t active;
jm 0:dedab08b24ea 34 uint8_t direction;
jm 0:dedab08b24ea 35 uint8_t tOff;
jm 0:dedab08b24ea 36 uint8_t tOn;
jm 0:dedab08b24ea 37 uint8_t state;
jm 0:dedab08b24ea 38 uint16_t dirPin;
jm 0:dedab08b24ea 39 uint16_t drivePin;
jm 0:dedab08b24ea 40 uint16_t eggTimer;
jm 0:dedab08b24ea 41 uint16_t cycles;
jm 0:dedab08b24ea 42 uint32_t dirBitValue;
jm 0:dedab08b24ea 43 LPC_GPIO_TypeDef * dirPort;
jm 0:dedab08b24ea 44 uint32_t driveBitValue;
jm 0:dedab08b24ea 45 LPC_GPIO_TypeDef * drivePort;
jm 0:dedab08b24ea 46 }sMotor[motorQty];
jm 0:dedab08b24ea 47 #endif
jm 0:dedab08b24ea 48
jm 0:dedab08b24ea 49 // Module Prototypes
jm 0:dedab08b24ea 50 void cli_Motor(void);
jm 0:dedab08b24ea 51 void MotorInit(void);
jm 0:dedab08b24ea 52 void MotorSM(void);
jm 0:dedab08b24ea 53 void cli_MotorSpeed(void);
jm 0:dedab08b24ea 54 void cli_GPPMT(void);
jm 0:dedab08b24ea 55 void rGPPMT(unsigned int id);
jm 0:dedab08b24ea 56
jm 0:dedab08b24ea 57 //-------------------------- CLIG PLUGS --------------------
jm 0:dedab08b24ea 58 // CLIG-INCLUDE
jm 0:dedab08b24ea 59 /*
jm 0:dedab08b24ea 60 #include "jmMotor.h"
jm 0:dedab08b24ea 61 */
jm 0:dedab08b24ea 62
jm 0:dedab08b24ea 63 // CLIG-CMD
jm 0:dedab08b24ea 64 /*
jm 0:dedab08b24ea 65 motor cli_Motor();
jm 0:dedab08b24ea 66 GPPMT cli_GPPMT();
jm 0:dedab08b24ea 67 motorSpeed cli_MotorSpeed();
jm 0:dedab08b24ea 68 */
jm 0:dedab08b24ea 69
jm 0:dedab08b24ea 70 // CLIG-INIT
jm 0:dedab08b24ea 71 /*
jm 0:dedab08b24ea 72 MotorInit();
jm 0:dedab08b24ea 73 */
jm 0:dedab08b24ea 74
jm 0:dedab08b24ea 75 // CLIG-TIMER
jm 0:dedab08b24ea 76 /*
jm 0:dedab08b24ea 77 // Module jmMotor
jm 0:dedab08b24ea 78 for(i=0;i<motorQty;i++)if(sMotor[i].eggTimer>0)sMotor[i].eggTimer--;
jm 0:dedab08b24ea 79 */
jm 0:dedab08b24ea 80
jm 0:dedab08b24ea 81 // CLIG-SM
jm 0:dedab08b24ea 82 /*
jm 0:dedab08b24ea 83 MotorSM();
jm 0:dedab08b24ea 84 */
jm 0:dedab08b24ea 85