converted the STEPPER_ENABLE_PIN to a STEPPER_DISABLE_PIN as per the request of Alden Hart of Grbl Shield fame.
This commit is contained in:
parent
74dcf58c5c
commit
c2aec12004
12
config.h
12
config.h
@ -26,9 +26,9 @@
|
||||
// Updated default pin-assignments from 0.6 onwards
|
||||
// (see bottom of file for a copy of the old config)
|
||||
|
||||
#define STEPPERS_ENABLE_DDR DDRB
|
||||
#define STEPPERS_ENABLE_PORT PORTB
|
||||
#define STEPPERS_ENABLE_BIT 0
|
||||
#define STEPPERS_DISABLE_DDR DDRB
|
||||
#define STEPPERS_DISABLE_PORT PORTB
|
||||
#define STEPPERS_DISABLE_BIT 0
|
||||
|
||||
#define STEPPING_DDR DDRD
|
||||
#define STEPPING_PORT PORTD
|
||||
@ -61,9 +61,9 @@
|
||||
|
||||
// Pin-assignments from Grbl 0.5
|
||||
|
||||
// #define STEPPERS_ENABLE_DDR DDRD
|
||||
// #define STEPPERS_ENABLE_PORT PORTD
|
||||
// #define STEPPERS_ENABLE_BIT 2
|
||||
// #define STEPPERS_DISABLE_DDR DDRD
|
||||
// #define STEPPERS_DISABLE_PORT PORTD
|
||||
// #define STEPPERS_DISABLE_BIT 2
|
||||
//
|
||||
// #define STEPPING_DDR DDRC
|
||||
// #define STEPPING_PORT PORTC
|
||||
|
3
main.c
3
main.c
@ -20,6 +20,7 @@
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <avr/sleep.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <util/delay.h>
|
||||
#include "planner.h"
|
||||
#include "stepper.h"
|
||||
@ -46,6 +47,8 @@ int main(void)
|
||||
gc_init();
|
||||
limits_init();
|
||||
|
||||
sei();
|
||||
|
||||
for(;;){
|
||||
sleep_mode(); // Wait for it ...
|
||||
protocol_process(); // ... process the serial protocol
|
||||
|
28
stepper.c
28
stepper.c
@ -43,9 +43,6 @@
|
||||
|
||||
#define MINIMUM_STEPS_PER_MINUTE 1200 // The stepper subsystem will never run slower than this, exept when sleeping
|
||||
|
||||
#define ENABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 |= (1<<OCIE1A)
|
||||
#define DISABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 &= ~(1<<OCIE1A)
|
||||
|
||||
static block_t *current_block; // A pointer to the block currently being traced
|
||||
|
||||
// Variables used by The Stepper Driver Interrupt
|
||||
@ -82,8 +79,17 @@ static uint32_t trapezoid_adjusted_rate; // The current rate of step_events
|
||||
static void set_step_events_per_minute(uint32_t steps_per_minute);
|
||||
|
||||
void st_wake_up() {
|
||||
STEPPERS_ENABLE_PORT |= (1<<STEPPERS_ENABLE_BIT);
|
||||
ENABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
// Enable steppers by resetting the stepper disable port
|
||||
STEPPERS_DISABLE_PORT &= ~(1<<STEPPERS_DISABLE_BIT);
|
||||
// Enable stepper driver interrupt
|
||||
TIMSK1 |= (1<<OCIE1A);
|
||||
}
|
||||
|
||||
static void st_go_idle() {
|
||||
// Disable steppers by setting stepper disable
|
||||
STEPPERS_DISABLE_PORT |= (1<<STEPPERS_DISABLE_BIT);
|
||||
// Disable stepper driver interrupt
|
||||
TIMSK1 &= ~(1<<OCIE1A);
|
||||
}
|
||||
|
||||
// Initializes the trapezoid generator from the current block. Called whenever a new
|
||||
@ -154,9 +160,7 @@ SIGNAL(TIMER1_COMPA_vect)
|
||||
counter_z = counter_x;
|
||||
step_events_completed = 0;
|
||||
} else {
|
||||
// set enable pin
|
||||
STEPPERS_ENABLE_PORT &= ~(1<<STEPPERS_ENABLE_BIT);
|
||||
DISABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
st_go_idle();
|
||||
}
|
||||
}
|
||||
|
||||
@ -214,7 +218,7 @@ void st_init()
|
||||
// Configure directions of interface pins
|
||||
STEPPING_DDR |= STEPPING_MASK;
|
||||
STEPPING_PORT = (STEPPING_PORT & ~STEPPING_MASK) | settings.invert_mask;
|
||||
STEPPERS_ENABLE_DDR |= 1<<STEPPERS_ENABLE_BIT;
|
||||
STEPPERS_DISABLE_DDR |= 1<<STEPPERS_DISABLE_BIT;
|
||||
|
||||
// waveform generation = 0100 = CTC
|
||||
TCCR1B &= ~(1<<WGM13);
|
||||
@ -234,10 +238,8 @@ void st_init()
|
||||
set_step_events_per_minute(6000);
|
||||
trapezoid_tick_cycle_counter = 0;
|
||||
|
||||
STEPPERS_ENABLE_PORT &= ~(1<<STEPPERS_ENABLE_BIT);
|
||||
DISABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
|
||||
sei();
|
||||
// Start in the idle state
|
||||
st_go_idle();
|
||||
}
|
||||
|
||||
// Block until all buffered steps are executed
|
||||
|
Loading…
Reference in New Issue
Block a user