diff --git a/main.c b/main.c index 030ae77..96d1929 100644 --- a/main.c +++ b/main.c @@ -33,13 +33,13 @@ int main(void) { - sp_init(); // initialize the serial protocol - settings_init(); - plan_init(); // initialize the stepper plan subsystem - st_init(); // initialize the stepper subsystem - spindle_init(); // initialize spindle controller - gc_init(); // initialize gcode-parser - + sp_init(); + settings_init(); + plan_init(); + st_init(); + spindle_init(); + gc_init(); + for(;;){ sleep_mode(); // Wait for it ... sp_process(); // ... process the serial protocol diff --git a/motion_control.c b/motion_control.c index 36c5bd8..f1f1b45 100644 --- a/motion_control.c +++ b/motion_control.c @@ -36,14 +36,6 @@ void mc_dwell(uint32_t milliseconds) _delay_ms(milliseconds); } -// Execute linear motion in absolute millimeter coordinates. Feed rate given in millimeters/second -// unless invert_feed_rate is true. Then the feed_rate means that the motion should be completed in -// 1/feed_rate minutes. -// void mc_line(double x, double y, double z, double feed_rate, int invert_feed_rate) -// { -// plan_buffer_line(x, y, z, feed_rate, invert_feed_rate); -// } - // Execute an arc. theta == start angle, angular_travel == number of radians to go along the arc, // positive angular_travel means clockwise, negative means counterclockwise. Radius == the radius of the // circle in millimeters. axis_1 and axis_2 selects the circle plane in tool space. Stick the remaining diff --git a/motion_control.h b/motion_control.h index 11123b0..d2f409b 100644 --- a/motion_control.h +++ b/motion_control.h @@ -28,9 +28,8 @@ // unless invert_feed_rate is true. Then the feed_rate means that the motion should be completed in // (1 minute)/feed_rate time. #define mc_line(x, y, z, feed_rate, invert_feed_rate) plan_buffer_line(x, y, z, feed_rate, invert_feed_rate) -// NOTE: Although this function structurally belongs in this module, there is nothing to to but -// to forward the request to the planner. For efficiency the function is replaced with a macro that -// just forwards the call to the planner. +// NOTE: Although this function structurally belongs in this module, there is nothing to do but +// to forward the request to the planner. For efficiency the function is implemented with a macro. // Execute an arc. theta == start angle, angular_travel == number of radians to go along the arc, // positive angular_travel means clockwise, negative means counterclockwise. Radius == the radius of the diff --git a/planner.c b/planner.c index 8102eec..90b93f2 100644 --- a/planner.c +++ b/planner.c @@ -66,12 +66,12 @@ // The number of linear motions that can be in the plan at any give time #define BLOCK_BUFFER_SIZE 20 -block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instructions -volatile int block_buffer_head; // Index of the next block to be pushed -volatile int block_buffer_tail; // Index of the block to process now +static block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instructions +static volatile int block_buffer_head; // Index of the next block to be pushed +static volatile int block_buffer_tail; // Index of the block to process now // The current position of the tool in absolute steps -int32_t position[3]; +static int32_t position[3]; static uint8_t acceleration_manager_enabled; // Acceleration management active? diff --git a/planner.h b/planner.h index b31ffb9..71524b9 100644 --- a/planner.h +++ b/planner.h @@ -51,8 +51,6 @@ typedef struct { } block_t; -extern int32_t position[3]; - // Initialize the motion plan subsystem void plan_init(); diff --git a/stepper.c b/stepper.c index d0828eb..933b847 100644 --- a/stepper.c +++ b/stepper.c @@ -55,7 +55,7 @@ static int32_t counter_x, // Counter variables for the bresenham line trac counter_y, counter_z; static uint32_t step_events_completed; // The number of step events executed in the current block -volatile int busy; // TRUE when SIG_OUTPUT_COMPARE1A is being serviced. Used to avoid retriggering that handler. +static volatile int busy; // TRUE when SIG_OUTPUT_COMPARE1A is being serviced. Used to avoid retriggering that handler. // Variables used by the trapezoid generation static uint32_t cycles_per_step_event; // The number of machine cycles between each step event