Control the Pololu SMC02B
SMC02B.h
- Committer:
- goncaloc
- Date:
- 2010-10-11
- Revision:
- 2:d14838eb6b4b
- Parent:
- 1:683f2848e917
- Child:
- 3:8595605248a3
File content as of revision 2:d14838eb6b4b:
/** * @author Gonçalo Costa * * @section LICENSE * * Copyright (c) 2010 ARM Limited * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * @section DESCRIPTION * * Pololu Micro Dual Serial Motor Controller. * * Datasheet: * * http://www.pololu.com/file/0J36/smc02b_guide.pdf */ #ifndef SMC02B_H #define SMC02B_H /** * Includes */ #include "mbed.h" /** * Defines */ #define SMC02B_START_BYTE 0x80 #define SMC02B_CONFIG_BYTE 0x02 #define SMC02B_DEVICE_ID 0x00 #define SMC02B_BYTE3 0x00 #define SMC02B_BYTE4 0x00 #define SMC02B_MOTOR1_DIR 0x00 #define SMC02B_MOTOR1_SPEED 0x00 #define SMC02B_MOTOR1_NUMBER 0x00 #define SMC02B_MOTOR2_DIR 0x00 #define SMC02B_MOTOR2_SPEED 0x00 #define SMC02B_MOTOR2_NUMBER 0x00 class SMC02B { public: /** * Constructor. * * @param tx mbed pin to use for TX line of Serial interface. * @param rx mbed pin to use for RX line of Serial interface. * @param rst mbed pin to use for RST line. */ SMC02B(PinName tx, PinName rx, PinName pin); /** * Reset SMC02B. * */ void SMC02B_RST(void); /** * Set Motor. * * @param motor Motor number. * @param Direction Motor Direction. * @param speed Motor Speed. */ void SMC02B_MOTOR_SET( char motor, char direction, char speed ); void SMC02B_MOTOR_BRAKE( char motor ); void SMC02B_MOTOR_COAST( char motor ); void SMC02B_CONFIG( char mode, char motor ); private: DigitalOut _rst; Serial* _SMC02B; }; #endif