2 #ifndef ARDUINO_ARCH_SAM 37 #if !defined(__AVR_ATmega32U4__) 44 #define MICROSTEPS 16 // 8 or 16 46 #define MOTOR12_64KHZ _BV(CS20) // no prescale 47 #define MOTOR12_8KHZ _BV(CS21) // divide by 8 48 #define MOTOR12_2KHZ _BV(CS21) | _BV(CS20) // divide by 32 49 #define MOTOR12_1KHZ _BV(CS22) // divide by 64 51 #define MOTOR34_64KHZ _BV(CS00) // no prescale 52 #define MOTOR34_8KHZ _BV(CS01) // divide by 8 53 #define MOTOR34_1KHZ _BV(CS01) | _BV(CS00) // divide by 64 55 #define DC_MOTOR_PWM_RATE MOTOR34_8KHZ // ANALOG rate for DC motors 56 #define STEPPER1_PWM_RATE MOTOR12_64KHZ // ANALOG rate for stepper 1 57 #define STEPPER2_PWM_RATE MOTOR34_64KHZ // ANALOG rate for stepper 2 59 #elif defined(__PIC32MX__) 68 #define MICROSTEPS 16 // 8 or 16 71 #define MOTOR12_312KHZ 0 // 1:1, actual frequency 312KHz 72 #define MOTOR12_156KHZ 1 // 1:2, actual frequency 156KHz 73 #define MOTOR12_64KHZ 2 // 1:4, actual frequency 78KHz 74 #define MOTOR12_39KHZ 3 // 1:8, acutal frequency 39KHz 75 #define MOTOR12_19KHZ 4 // 1:16, actual frequency 19KHz 76 #define MOTOR12_8KHZ 5 // 1:32, actual frequency 9.7KHz 77 #define MOTOR12_4_8KHZ 6 // 1:64, actual frequency 4.8KHz 78 #define MOTOR12_2KHZ 7 // 1:256, actual frequency 1.2KHz 79 #define MOTOR12_1KHZ 7 // 1:256, actual frequency 1.2KHz 81 #define MOTOR34_312KHZ 0 // 1:1, actual frequency 312KHz 82 #define MOTOR34_156KHZ 1 // 1:2, actual frequency 156KHz 83 #define MOTOR34_64KHZ 2 // 1:4, actual frequency 78KHz 84 #define MOTOR34_39KHZ 3 // 1:8, acutal frequency 39KHz 85 #define MOTOR34_19KHZ 4 // 1:16, actual frequency 19KHz 86 #define MOTOR34_8KHZ 5 // 1:32, actual frequency 9.7KHz 87 #define MOTOR34_4_8KHZ 6 // 1:64, actual frequency 4.8KHz 88 #define MOTOR34_2KHZ 7 // 1:256, actual frequency 1.2KHz 89 #define MOTOR34_1KHZ 7 // 1:256, actual frequency 1.2KHz 92 #define DC_MOTOR_PWM_RATE MOTOR34_39KHZ 95 #define STEPPER1_PWM_RATE MOTOR12_39KHZ 96 #define STEPPER2_PWM_RATE MOTOR34_39KHZ 141 #define MOTORLATCH 12 143 #define MOTORENABLE 7 153 uint8_t TimerInitalized;
159 AF_DCMotor(uint8_t motornum, uint8_t freq = DC_MOTOR_PWM_RATE);
161 void setSpeed(uint8_t);
164 uint8_t motornum, pwmfreq;
170 void step(uint16_t steps, uint8_t dir, uint8_t style = SINGLE);
171 void setSpeed(uint16_t);
172 uint8_t onestep(uint8_t dir, uint8_t style);
176 uint32_t usperstep, steppingcounter;
182 uint8_t getlatchstate(
void);