step, dir, enable ports
This commit is contained in:
parent
f5a117d0ba
commit
bbbdb60076
@ -28,6 +28,7 @@
|
||||
#ifndef config_h
|
||||
#define config_h
|
||||
#include "grbl.h" // For Arduino IDE compatibility.
|
||||
#include "LPC17xx.h"
|
||||
|
||||
|
||||
// Define CPU pin map and default settings.
|
||||
@ -584,26 +585,28 @@
|
||||
#define SERIAL_UDRE USART_UDRE_vect
|
||||
|
||||
// Define step pulse output pins. NOTE: All step bit pins must be on the same port.
|
||||
#define STEP_DDR DDRD
|
||||
#define STEP_PORT PORTD
|
||||
#define X_STEP_BIT 2 // Uno Digital Pin 2
|
||||
#define Y_STEP_BIT 3 // Uno Digital Pin 3
|
||||
#define Z_STEP_BIT 4 // Uno Digital Pin 4
|
||||
#define STEP_DDR LPC_GPIO2->FIODIR
|
||||
#define STEP_PORT LPC_GPIO2->FIOPIN
|
||||
#define X_STEP_BIT 0
|
||||
#define Y_STEP_BIT 1
|
||||
#define Z_STEP_BIT 2
|
||||
#define STEP_MASK ((1<<X_STEP_BIT)|(1<<Y_STEP_BIT)|(1<<Z_STEP_BIT)) // All step bits
|
||||
|
||||
// Define step direction output pins. NOTE: All direction pins must be on the same port.
|
||||
#define DIRECTION_DDR DDRD
|
||||
#define DIRECTION_PORT PORTD
|
||||
#define X_DIRECTION_BIT 5 // Uno Digital Pin 5
|
||||
#define Y_DIRECTION_BIT 6 // Uno Digital Pin 6
|
||||
#define Z_DIRECTION_BIT 7 // Uno Digital Pin 7
|
||||
#define DIRECTION_DDR LPC_GPIO0->FIODIR
|
||||
#define DIRECTION_PORT LPC_GPIO0->FIOPIN
|
||||
#define X_DIRECTION_BIT 5
|
||||
#define Y_DIRECTION_BIT 11
|
||||
#define Z_DIRECTION_BIT 20
|
||||
#define DIRECTION_MASK ((1<<X_DIRECTION_BIT)|(1<<Y_DIRECTION_BIT)|(1<<Z_DIRECTION_BIT)) // All direction bits
|
||||
|
||||
// Define stepper driver enable/disable output pin.
|
||||
#define STEPPERS_DISABLE_DDR DDRB
|
||||
#define STEPPERS_DISABLE_PORT PORTB
|
||||
#define STEPPERS_DISABLE_BIT 0 // Uno Digital Pin 8
|
||||
#define STEPPERS_DISABLE_MASK (1<<STEPPERS_DISABLE_BIT)
|
||||
#define STEPPERS_DISABLE_DDR LPC_GPIO0->FIODIR
|
||||
#define STEPPERS_DISABLE_PORT LPC_GPIO0->FIOPIN
|
||||
#define X_DISABLE_BIT 4
|
||||
#define Y_DISABLE_BIT 10
|
||||
#define Z_DISABLE_BIT 19
|
||||
#define STEPPERS_DISABLE_MASK ((1<<X_DISABLE_BIT)|(1<<Y_DISABLE_BIT)|(1<<Z_DISABLE_BIT))
|
||||
|
||||
// Define homing/hard limit switch input pins and limit interrupt vectors.
|
||||
// NOTE: All limit bit pins must be on the same port, but not on a port with other input pins (CONTROL).
|
||||
@ -725,7 +728,7 @@
|
||||
#define DEFAULT_SOFT_LIMIT_ENABLE 0 // false
|
||||
#define DEFAULT_HARD_LIMIT_ENABLE 0 // false
|
||||
#define DEFAULT_INVERT_PROBE_PIN 0 // false
|
||||
#define DEFAULT_LASER_MODE 0 // false
|
||||
#define DEFAULT_LASER_MODE 1 // true
|
||||
#define DEFAULT_HOMING_ENABLE 0 // false
|
||||
#define DEFAULT_HOMING_DIR_MASK 0 // move positive dir
|
||||
#define DEFAULT_HOMING_FEED_RATE 25.0 // mm/min
|
||||
|
@ -158,7 +158,7 @@ void limits_go_home(uint8_t cycle_mask)
|
||||
|
||||
// Initialize variables used for homing computations.
|
||||
uint8_t n_cycle = (2*N_HOMING_LOCATE_CYCLE+1);
|
||||
uint8_t step_pin[N_AXIS];
|
||||
uint32_t step_pin[N_AXIS];
|
||||
float target[N_AXIS];
|
||||
float max_travel = 0.0;
|
||||
uint8_t idx;
|
||||
@ -180,7 +180,7 @@ void limits_go_home(uint8_t cycle_mask)
|
||||
bool approach = true;
|
||||
float homing_rate = settings.homing_seek_rate;
|
||||
|
||||
uint8_t limit_state, axislock, n_active_axis;
|
||||
uint32_t limit_state, axislock, n_active_axis;
|
||||
do {
|
||||
|
||||
system_convert_array_steps_to_mpos(target,sys_position);
|
||||
|
@ -56,7 +56,7 @@ typedef struct {
|
||||
// NOTE: Used by stepper algorithm to execute the block correctly. Do not alter these values.
|
||||
uint32_t steps[N_AXIS]; // Step count along each axis
|
||||
uint32_t step_event_count; // The maximum step axis count and number of steps required to complete this block.
|
||||
uint8_t direction_bits; // The direction bit set for this block (refers to *_DIRECTION_BIT in config.h)
|
||||
uint32_t direction_bits; // The direction bit set for this block (refers to *_DIRECTION_BIT in config.h)
|
||||
|
||||
// Block condition data to ensure correct execution depending on states and overrides.
|
||||
uint8_t condition; // Block bitflag variable defining block run conditions. Copied from pl_line_data.
|
||||
|
@ -317,7 +317,7 @@ void settings_init() {
|
||||
|
||||
|
||||
// Returns step pin mask according to Grbl internal axis indexing.
|
||||
uint8_t get_step_pin_mask(uint8_t axis_idx)
|
||||
uint32_t get_step_pin_mask(uint8_t axis_idx)
|
||||
{
|
||||
if ( axis_idx == X_AXIS ) { return((1<<X_STEP_BIT)); }
|
||||
if ( axis_idx == Y_AXIS ) { return((1<<Y_STEP_BIT)); }
|
||||
@ -326,7 +326,7 @@ uint8_t get_step_pin_mask(uint8_t axis_idx)
|
||||
|
||||
|
||||
// Returns direction pin mask according to Grbl internal axis indexing.
|
||||
uint8_t get_direction_pin_mask(uint8_t axis_idx)
|
||||
uint32_t get_direction_pin_mask(uint8_t axis_idx)
|
||||
{
|
||||
if ( axis_idx == X_AXIS ) { return((1<<X_DIRECTION_BIT)); }
|
||||
if ( axis_idx == Y_AXIS ) { return((1<<Y_DIRECTION_BIT)); }
|
||||
|
@ -132,10 +132,10 @@ void settings_write_coord_data(uint8_t coord_select, float *coord_data);
|
||||
uint8_t settings_read_coord_data(uint8_t coord_select, float *coord_data);
|
||||
|
||||
// Returns the step pin mask according to Grbl's internal axis numbering
|
||||
uint8_t get_step_pin_mask(uint8_t i);
|
||||
uint32_t get_step_pin_mask(uint8_t i);
|
||||
|
||||
// Returns the direction pin mask according to Grbl's internal axis numbering
|
||||
uint8_t get_direction_pin_mask(uint8_t i);
|
||||
uint32_t get_direction_pin_mask(uint8_t i);
|
||||
|
||||
// Returns the limit pin mask according to Grbl's internal axis numbering
|
||||
uint8_t get_limit_pin_mask(uint8_t i);
|
||||
|
@ -60,7 +60,7 @@
|
||||
typedef struct {
|
||||
uint32_t steps[N_AXIS];
|
||||
uint32_t step_event_count;
|
||||
uint8_t direction_bits;
|
||||
uint32_t direction_bits;
|
||||
#ifdef VARIABLE_SPINDLE
|
||||
uint8_t is_pwm_rate_adjusted; // Tracks motions that require constant laser power/rate
|
||||
#endif
|
||||
@ -93,13 +93,13 @@ typedef struct {
|
||||
counter_y,
|
||||
counter_z;
|
||||
#ifdef STEP_PULSE_DELAY
|
||||
uint8_t step_bits; // Stores out_bits output to complete the step pulse delay
|
||||
uint32_t step_bits; // Stores out_bits output to complete the step pulse delay
|
||||
#endif
|
||||
|
||||
uint8_t execute_step; // Flags step execution for each interrupt.
|
||||
uint8_t step_pulse_time; // Step pulse reset time after step rise
|
||||
uint8_t step_outbits; // The next stepping-bits to be output
|
||||
uint8_t dir_outbits;
|
||||
uint32_t step_outbits; // The next stepping-bits to be output
|
||||
uint32_t dir_outbits;
|
||||
#ifdef ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING
|
||||
uint32_t steps[N_AXIS];
|
||||
#endif
|
||||
@ -117,8 +117,8 @@ static uint8_t segment_buffer_head;
|
||||
static uint8_t segment_next_head;
|
||||
|
||||
// Step and direction port invert masks.
|
||||
static uint8_t step_port_invert_mask;
|
||||
static uint8_t dir_port_invert_mask;
|
||||
static uint32_t step_port_invert_mask;
|
||||
static uint32_t dir_port_invert_mask;
|
||||
|
||||
// Used to avoid ISR nesting of the "Stepper Driver Interrupt". Should never occur though.
|
||||
static volatile uint8_t busy;
|
||||
@ -207,8 +207,8 @@ static st_prep_t prep;
|
||||
void st_wake_up()
|
||||
{
|
||||
// Enable stepper drivers.
|
||||
if (bit_istrue(settings.flags,BITFLAG_INVERT_ST_ENABLE)) { STEPPERS_DISABLE_PORT |= (1<<STEPPERS_DISABLE_BIT); }
|
||||
else { STEPPERS_DISABLE_PORT &= ~(1<<STEPPERS_DISABLE_BIT); }
|
||||
if (bit_istrue(settings.flags,BITFLAG_INVERT_ST_ENABLE)) { STEPPERS_DISABLE_PORT |= STEPPERS_DISABLE_MASK; }
|
||||
else { STEPPERS_DISABLE_PORT &= ~STEPPERS_DISABLE_MASK; }
|
||||
|
||||
// Initialize stepper output bits to ensure first ISR call does not step.
|
||||
st.step_outbits = step_port_invert_mask;
|
||||
@ -246,8 +246,8 @@ void st_go_idle()
|
||||
pin_state = true; // Override. Disable steppers.
|
||||
}
|
||||
if (bit_istrue(settings.flags,BITFLAG_INVERT_ST_ENABLE)) { pin_state = !pin_state; } // Apply pin invert.
|
||||
if (pin_state) { STEPPERS_DISABLE_PORT |= (1<<STEPPERS_DISABLE_BIT); }
|
||||
else { STEPPERS_DISABLE_PORT &= ~(1<<STEPPERS_DISABLE_BIT); }
|
||||
if (pin_state) { STEPPERS_DISABLE_PORT |= STEPPERS_DISABLE_MASK; }
|
||||
else { STEPPERS_DISABLE_PORT &= ~STEPPERS_DISABLE_MASK; }
|
||||
}
|
||||
|
||||
|
||||
@ -502,7 +502,7 @@ void stepper_init()
|
||||
{
|
||||
// Configure step and direction interface pins
|
||||
STEP_DDR |= STEP_MASK;
|
||||
STEPPERS_DISABLE_DDR |= 1<<STEPPERS_DISABLE_BIT;
|
||||
STEPPERS_DISABLE_DDR |= STEPPERS_DISABLE_MASK;
|
||||
DIRECTION_DDR |= DIRECTION_MASK;
|
||||
|
||||
// Configure Timer 1: Stepper Driver Interrupt
|
||||
|
@ -130,7 +130,7 @@ typedef struct {
|
||||
uint8_t soft_limit; // Tracks soft limit errors for the state machine. (boolean)
|
||||
uint8_t step_control; // Governs the step segment generator depending on system state.
|
||||
uint8_t probe_succeeded; // Tracks if last probing cycle was successful.
|
||||
uint8_t homing_axis_lock; // Locks axes when limits engage. Used as an axis motion mask in the stepper ISR.
|
||||
uint32_t homing_axis_lock; // Locks axes when limits engage. Used as an axis motion mask in the stepper ISR.
|
||||
uint8_t f_override; // Feed rate override value in percent
|
||||
uint8_t r_override; // Rapids override value in percent
|
||||
uint8_t spindle_speed_ovr; // Spindle speed value in percent
|
||||
|
Loading…
Reference in New Issue
Block a user