Library for ST's new dSpin stepper motor driver. Works with their demo board L6470EVAL.
dSPIN.h@0:3a9b958ba85f, 2012-07-09 (annotated)
- Committer:
- thorlabs
- Date:
- Mon Jul 09 14:40:14 2012 +0000
- Revision:
- 0:3a9b958ba85f
[mbed] converted /RS485_Repeater_11U24_beta/dSPIN
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thorlabs | 0:3a9b958ba85f | 1 | /** |
thorlabs | 0:3a9b958ba85f | 2 | * @author Eric Lieser |
thorlabs | 0:3a9b958ba85f | 3 | * |
thorlabs | 0:3a9b958ba85f | 4 | * @section LICENSE |
thorlabs | 0:3a9b958ba85f | 5 | * |
thorlabs | 0:3a9b958ba85f | 6 | * Copyright (c) 2010 ARM Limited |
thorlabs | 0:3a9b958ba85f | 7 | * |
thorlabs | 0:3a9b958ba85f | 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
thorlabs | 0:3a9b958ba85f | 9 | * of this software and associated documentation files (the "Software"), to deal |
thorlabs | 0:3a9b958ba85f | 10 | * in the Software without restriction, including without limitation the rights |
thorlabs | 0:3a9b958ba85f | 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
thorlabs | 0:3a9b958ba85f | 12 | * copies of the Software, and to permit persons to whom the Software is |
thorlabs | 0:3a9b958ba85f | 13 | * furnished to do so, subject to the following conditions: |
thorlabs | 0:3a9b958ba85f | 14 | * |
thorlabs | 0:3a9b958ba85f | 15 | * The above copyright notice and this permission notice shall be included in |
thorlabs | 0:3a9b958ba85f | 16 | * all copies or substantial portions of the Software. |
thorlabs | 0:3a9b958ba85f | 17 | * |
thorlabs | 0:3a9b958ba85f | 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
thorlabs | 0:3a9b958ba85f | 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
thorlabs | 0:3a9b958ba85f | 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
thorlabs | 0:3a9b958ba85f | 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
thorlabs | 0:3a9b958ba85f | 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
thorlabs | 0:3a9b958ba85f | 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
thorlabs | 0:3a9b958ba85f | 24 | * THE SOFTWARE. |
thorlabs | 0:3a9b958ba85f | 25 | * |
thorlabs | 0:3a9b958ba85f | 26 | * @section DESCRIPTION |
thorlabs | 0:3a9b958ba85f | 27 | * |
thorlabs | 0:3a9b958ba85f | 28 | * ST Microelectronics L6470 dSPIN fully integrated microstepping motor driver |
thorlabs | 0:3a9b958ba85f | 29 | * with motion engine and SPI |
thorlabs | 0:3a9b958ba85f | 30 | * |
thorlabs | 0:3a9b958ba85f | 31 | * Datasheet: http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/DATASHEET/CD00255075.pdf |
thorlabs | 0:3a9b958ba85f | 32 | * |
thorlabs | 0:3a9b958ba85f | 33 | * |
thorlabs | 0:3a9b958ba85f | 34 | */ |
thorlabs | 0:3a9b958ba85f | 35 | |
thorlabs | 0:3a9b958ba85f | 36 | #ifndef dSPIN_H |
thorlabs | 0:3a9b958ba85f | 37 | #define dSPIN_H |
thorlabs | 0:3a9b958ba85f | 38 | |
thorlabs | 0:3a9b958ba85f | 39 | |
thorlabs | 0:3a9b958ba85f | 40 | /** |
thorlabs | 0:3a9b958ba85f | 41 | * Includes |
thorlabs | 0:3a9b958ba85f | 42 | */ |
thorlabs | 0:3a9b958ba85f | 43 | #include "mbed.h" |
thorlabs | 0:3a9b958ba85f | 44 | |
thorlabs | 0:3a9b958ba85f | 45 | /** |
thorlabs | 0:3a9b958ba85f | 46 | * Defines |
thorlabs | 0:3a9b958ba85f | 47 | */ |
thorlabs | 0:3a9b958ba85f | 48 | #define ABS_POS 0x01 //length: 22 reset value: 0 |
thorlabs | 0:3a9b958ba85f | 49 | #define EL_POS 0x02 //length: 9 reset value: 0 |
thorlabs | 0:3a9b958ba85f | 50 | #define MARK 0x03 //length: 22 reset value: 0 |
thorlabs | 0:3a9b958ba85f | 51 | #define SPEED 0x04 //length: 20 reset value: 0 |
thorlabs | 0:3a9b958ba85f | 52 | #define ACC 0x05 //length: 12 reset value: 08A |
thorlabs | 0:3a9b958ba85f | 53 | #define DEC 0x06 //length: 12 reset value: 08A |
thorlabs | 0:3a9b958ba85f | 54 | #define MAX_SPEED 0x07 //length: 10 reset value: 41 |
thorlabs | 0:3a9b958ba85f | 55 | #define MIN_SPEED 0x08 //length: 13 reset value: 0 |
thorlabs | 0:3a9b958ba85f | 56 | #define FS_SPD 0x15 //length: 10 reset value: 027 |
thorlabs | 0:3a9b958ba85f | 57 | #define KVAL_HOLD 0x09 //length: 8 reset value: 29 |
thorlabs | 0:3a9b958ba85f | 58 | #define KVAL_RUN 0x0A //length: 8 reset value: 29 |
thorlabs | 0:3a9b958ba85f | 59 | #define KVAL_ACC 0x0B //length: 8 reset value: 29 |
thorlabs | 0:3a9b958ba85f | 60 | #define KVAL_DEC 0x0C //length: 8 reset value: 29 |
thorlabs | 0:3a9b958ba85f | 61 | #define INT_SPD 0x0D //length: 14 reset value: 0408 |
thorlabs | 0:3a9b958ba85f | 62 | #define ST_SLP 0x0E //length: 8 reset value: 19 |
thorlabs | 0:3a9b958ba85f | 63 | #define FN_SLP_ACC 0x0F //length: 8 reset value: 29 |
thorlabs | 0:3a9b958ba85f | 64 | #define FN_SLP_DEC 0x10 //length: 8 reset value: 29 |
thorlabs | 0:3a9b958ba85f | 65 | #define K_THERM 0x11 //length: 4 reset value: 0 |
thorlabs | 0:3a9b958ba85f | 66 | #define ADC_OUT 0x12 //length: 5 reset value: |
thorlabs | 0:3a9b958ba85f | 67 | #define OCD_TH 0x13 //length: 4 reset value: 8 |
thorlabs | 0:3a9b958ba85f | 68 | #define STALL_TH 0x14 //length: 7 reset value: 40 |
thorlabs | 0:3a9b958ba85f | 69 | #define STEP_MODE 0x16 //length: 8 reset value: 7 |
thorlabs | 0:3a9b958ba85f | 70 | #define ALARM_EN 0x17 //length: 8 reset value: FF |
thorlabs | 0:3a9b958ba85f | 71 | #define CONFIG 0x18 //length: 16 reset value: 2E88 |
thorlabs | 0:3a9b958ba85f | 72 | #define STATUS 0x19 //length: 16 reset value: |
thorlabs | 0:3a9b958ba85f | 73 | |
thorlabs | 0:3a9b958ba85f | 74 | /** |
thorlabs | 0:3a9b958ba85f | 75 | * ST Micro dSPIN stepper motor controller |
thorlabs | 0:3a9b958ba85f | 76 | */ |
thorlabs | 0:3a9b958ba85f | 77 | class dSPIN { |
thorlabs | 0:3a9b958ba85f | 78 | |
thorlabs | 0:3a9b958ba85f | 79 | public: |
thorlabs | 0:3a9b958ba85f | 80 | |
thorlabs | 0:3a9b958ba85f | 81 | /** |
thorlabs | 0:3a9b958ba85f | 82 | * Constructor. |
thorlabs | 0:3a9b958ba85f | 83 | * |
thorlabs | 0:3a9b958ba85f | 84 | * @param mosi mbed pin to use for MOSI line of SPI interface. |
thorlabs | 0:3a9b958ba85f | 85 | * @param miso mbed pin to use for MISO line of SPI interface. |
thorlabs | 0:3a9b958ba85f | 86 | * @param sck mbed pin to use for SCK line of SPI interface. |
thorlabs | 0:3a9b958ba85f | 87 | * @param cs mbed pin to use for not chip select line of SPI interface. |
thorlabs | 0:3a9b958ba85f | 88 | */ |
thorlabs | 0:3a9b958ba85f | 89 | dSPIN(PinName mosi, PinName miso, PinName sck, PinName cs); |
thorlabs | 0:3a9b958ba85f | 90 | |
thorlabs | 0:3a9b958ba85f | 91 | void run(int dir, int speed); |
thorlabs | 0:3a9b958ba85f | 92 | |
thorlabs | 0:3a9b958ba85f | 93 | void move(int dir, int steps); |
thorlabs | 0:3a9b958ba85f | 94 | |
thorlabs | 0:3a9b958ba85f | 95 | void soft_stop(void); |
thorlabs | 0:3a9b958ba85f | 96 | |
thorlabs | 0:3a9b958ba85f | 97 | void set_param(char parameter, int length, int value); |
thorlabs | 0:3a9b958ba85f | 98 | |
thorlabs | 0:3a9b958ba85f | 99 | int get_param(char parameter, int length); |
thorlabs | 0:3a9b958ba85f | 100 | |
thorlabs | 0:3a9b958ba85f | 101 | int get_status(void); |
thorlabs | 0:3a9b958ba85f | 102 | |
thorlabs | 0:3a9b958ba85f | 103 | void reset_device(void); |
thorlabs | 0:3a9b958ba85f | 104 | |
thorlabs | 0:3a9b958ba85f | 105 | private: |
thorlabs | 0:3a9b958ba85f | 106 | |
thorlabs | 0:3a9b958ba85f | 107 | SPI spi_; |
thorlabs | 0:3a9b958ba85f | 108 | DigitalOut nCS_; |
thorlabs | 0:3a9b958ba85f | 109 | |
thorlabs | 0:3a9b958ba85f | 110 | }; |
thorlabs | 0:3a9b958ba85f | 111 | |
thorlabs | 0:3a9b958ba85f | 112 | |
thorlabs | 0:3a9b958ba85f | 113 | |
thorlabs | 0:3a9b958ba85f | 114 | #endif /* dSPIN */ |