Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Microduino_Stepper.h
00001 // Microduino_Stepper.cpp 00002 // 00003 // Copyright (C) 2009-2013 Shenyang 00004 // $Id: Microduino_Stepper.cpp,v 1.00 2016/04/07 $ 00005 #if 0 00006 #ifndef __MICRODUINO_STEPPER_H__ 00007 #define __MICRODUINO_STEPPER_H__ 00008 00009 //#include "MicroduinoPinNames.h" 00010 #include "mbed.h" 00011 #include <stdlib.h> 00012 //#include <Arduino.h> 00013 00014 //#define _useTimer1 00015 #define MAX_SPEED_S 4096 00016 #define TIMER_COMP 327680/MAX_SPEED_S 00017 00018 00019 #define PIN_SET(pin) (*portOutputRegister(digitalPinToPort(pin)) |= digitalPinToBitMask(pin)) 00020 #define PIN_CLR(pin) (*portOutputRegister(digitalPinToPort(pin)) &= ~digitalPinToBitMask(pin)) 00021 00022 #define MAX_STEPPERS 4 00023 #define INVALID_STEPPER 255 00024 00025 #if 0 00026 #define PIN_EN 4 //PORTB,0 00027 #define PIN_DIRA A0 //PORTA,7 00028 #define PIN_STEPA 5 //PORTB,1 00029 #define PIN_DIRB A1 //PORTA,6 00030 #define PIN_STEPB 6 //PORTB,2 00031 #define PIN_DIRC A2 //PORTA,5 00032 #define PIN_STEPC 7 //PORTB,3 00033 #define PIN_DIRD A3 //PORTA,4 00034 #define PIN_STEPD 8 //PORTD,6 00035 #elif 0 00036 #define PIN_EN D4 00037 #define PIN_DIRA A0 00038 #define PIN_STEPA D5 00039 #define PIN_DIRB A1 00040 #define PIN_STEPB D6 00041 #define PIN_DIRC A2 00042 #define PIN_STEPC D7 00043 #define PIN_DIRD A3 00044 #define PIN_STEPD D8 00045 #else 00046 #define PIN_EN P0_25 00047 #define PIN_DIRA P0_7 00048 #define PIN_STEPA P0_24 00049 #define PIN_DIRB P0_6 00050 #define PIN_STEPB P0_1 00051 #define PIN_DIRC P0_14 00052 #define PIN_STEPC P0_20 00053 #define PIN_DIRD P0_23 00054 #define PIN_STEPD P0_19 00055 #endif 00056 00057 #define DEFAULT_ACCEL 120 00058 00059 void stepperAllEnable(); 00060 void stepperAllDisable(); 00061 00062 class Stepper 00063 { 00064 public: 00065 00066 Stepper(uint8_t _dirPin, uint8_t _stepPin); 00067 00068 uint8_t begin(); 00069 00070 void setSpeed(int16_t _speed); 00071 00072 void setMaxAccel(uint16_t _accel); 00073 00074 int16_t getSpeed(); 00075 00076 uint16_t getMaxAccel(); 00077 00078 void computeStep(); 00079 00080 private: 00081 00082 gpio_t dirOUT; 00083 gpio_t stepOUT; 00084 uint8_t stepperIndex; 00085 uint8_t dirPin; 00086 uint8_t stepPin; 00087 int16_t speed; 00088 uint16_t maxAccel; 00089 uint16_t period; 00090 uint16_t counter; 00091 00092 }; 00093 00094 typedef struct { 00095 //uint8_t isActive = false; 00096 uint8_t isActive; 00097 Stepper *stepper; 00098 } Stepper_t; 00099 00100 #endif 00101 #endif
Generated on Wed Jul 13 2022 03:34:51 by
1.7.2