This class interface the MDSMC (Micro Dual Serial Motor Controller) by Pololu with our mbed module
Embed:
(wiki syntax)
Show/hide line numbers
MDSMC.cpp
00001 //.cpp file of MDSMC library 00002 00003 #include "mbed.h" 00004 #include "MDSMC.h" 00005 00006 MDSMC::MDSMC(PinName TX, PinName RX, PinName CLR, int bps, int nM): _serialMDSMC(TX, RX), _CLR(CLR) 00007 { 00008 reset(); 00009 _serialMDSMC.baud(bps); 00010 switch (nM) 00011 { 00012 case 1: 00013 _serialMDSMC.putc(Start); 00014 _serialMDSMC.putc(ChangeConfig); 00015 _serialMDSMC.putc(Setting1); 00016 reset(); 00017 break; 00018 case 2: 00019 _serialMDSMC.putc(Start); 00020 _serialMDSMC.putc(ChangeConfig); 00021 _serialMDSMC.putc(Setting2); 00022 reset(); 00023 break; 00024 } 00025 } 00026 00027 //user functions 00028 void MDSMC::use(char direction, char speed) 00029 { 00030 _serialMDSMC.putc(Start); 00031 _serialMDSMC.putc(Device); 00032 _serialMDSMC.putc(direction); 00033 _serialMDSMC.putc(speed); 00034 } 00035 00036 void MDSMC::reset() 00037 { 00038 _CLR = 0; 00039 wait_us(2); 00040 _CLR = 1; 00041 } 00042 00043
Generated on Sun Jul 24 2022 15:55:29 by
1.7.2