This class interface the MDSMC (Micro Dual Serial Motor Controller) by Pololu with our mbed module

Committer:
fangoman91
Date:
Fri Nov 16 20:26:54 2012 +0000
Revision:
0:e869912db757
this class interface the MDSMC (Micro Dual Serial Motor Controller) by pololu

Who changed what in which revision?

UserRevisionLine numberNew contents of line
fangoman91 0:e869912db757 1 //.cpp file of MDSMC library
fangoman91 0:e869912db757 2
fangoman91 0:e869912db757 3 #include "mbed.h"
fangoman91 0:e869912db757 4 #include "MDSMC.h"
fangoman91 0:e869912db757 5
fangoman91 0:e869912db757 6 MDSMC::MDSMC(PinName TX, PinName RX, PinName CLR, int bps, int nM): _serialMDSMC(TX, RX), _CLR(CLR)
fangoman91 0:e869912db757 7 {
fangoman91 0:e869912db757 8 reset();
fangoman91 0:e869912db757 9 _serialMDSMC.baud(bps);
fangoman91 0:e869912db757 10 switch (nM)
fangoman91 0:e869912db757 11 {
fangoman91 0:e869912db757 12 case 1:
fangoman91 0:e869912db757 13 _serialMDSMC.putc(Start);
fangoman91 0:e869912db757 14 _serialMDSMC.putc(ChangeConfig);
fangoman91 0:e869912db757 15 _serialMDSMC.putc(Setting1);
fangoman91 0:e869912db757 16 reset();
fangoman91 0:e869912db757 17 break;
fangoman91 0:e869912db757 18 case 2:
fangoman91 0:e869912db757 19 _serialMDSMC.putc(Start);
fangoman91 0:e869912db757 20 _serialMDSMC.putc(ChangeConfig);
fangoman91 0:e869912db757 21 _serialMDSMC.putc(Setting2);
fangoman91 0:e869912db757 22 reset();
fangoman91 0:e869912db757 23 break;
fangoman91 0:e869912db757 24 }
fangoman91 0:e869912db757 25 }
fangoman91 0:e869912db757 26
fangoman91 0:e869912db757 27 //user functions
fangoman91 0:e869912db757 28 void MDSMC::use(char direction, char speed)
fangoman91 0:e869912db757 29 {
fangoman91 0:e869912db757 30 _serialMDSMC.putc(Start);
fangoman91 0:e869912db757 31 _serialMDSMC.putc(Device);
fangoman91 0:e869912db757 32 _serialMDSMC.putc(direction);
fangoman91 0:e869912db757 33 _serialMDSMC.putc(speed);
fangoman91 0:e869912db757 34 }
fangoman91 0:e869912db757 35
fangoman91 0:e869912db757 36 void MDSMC::reset()
fangoman91 0:e869912db757 37 {
fangoman91 0:e869912db757 38 _CLR = 0;
fangoman91 0:e869912db757 39 wait_us(2);
fangoman91 0:e869912db757 40 _CLR = 1;
fangoman91 0:e869912db757 41 }
fangoman91 0:e869912db757 42
fangoman91 0:e869912db757 43