00001 #ifndef _DDA_H
00002 #define _DDA_H
00003
00004 #include <stdint.h>
00005
00006 #include "config.h"
00007
00008 #ifdef ACCELERATION_REPRAP
00009 #ifdef ACCELERATION_RAMPING
00010 #error Cant use ACCELERATION_REPRAP and ACCELERATION_RAMPING together.
00011 #endif
00012 #endif
00013
00014
00015
00016
00017
00018 typedef enum {
00019 RAMP_UP,
00020 RAMP_MAX,
00021 RAMP_DOWN
00022 } ramp_state_t;
00023
00024
00025
00026
00027
00028
00029 typedef struct {
00030 int32_t X;
00031 int32_t Y;
00032 int32_t Z;
00033 int32_t E;
00034 uint32_t F;
00035 } TARGET;
00036
00044 typedef struct {
00046 TARGET endpoint;
00047
00048 union {
00049 struct {
00050
00051 uint8_t nullmove :1;
00052 uint8_t live :1;
00053 #ifdef ACCELERATION_REPRAP
00054 uint8_t accel :1;
00055 #endif
00056
00057
00058 uint8_t waitfor_temp :1;
00059
00060
00061 uint8_t x_direction :1;
00062 uint8_t y_direction :1;
00063 uint8_t z_direction :1;
00064 uint8_t e_direction :1;
00065 };
00066 uint8_t allflags;
00067 };
00068
00069
00070 uint32_t x_delta;
00071 uint32_t y_delta;
00072 uint32_t z_delta;
00073 uint32_t e_delta;
00074
00075
00076 int32_t x_counter;
00077 int32_t y_counter;
00078 int32_t z_counter;
00079 int32_t e_counter;
00080
00082 uint32_t total_steps;
00083
00084
00085 uint32_t c;
00086 #ifdef ACCELERATION_REPRAP
00087 uint32_t end_c;
00088 int32_t n;
00089 #endif
00090 #ifdef ACCELERATION_RAMPING
00091
00092 uint32_t ramp_steps;
00094 uint32_t step_no;
00096 uint32_t c_min;
00098 int32_t n;
00100 ramp_state_t ramp_state;
00101 #endif
00102 #ifdef ACCELERATION_TEMPORAL
00103
00104 uint32_t x_step_interval;
00106 uint32_t y_step_interval;
00108 uint32_t z_step_interval;
00110 uint32_t e_step_interval;
00111 #endif
00112 } DDA;
00113
00114
00115
00116
00117
00119 extern uint8_t steptimeout;
00120
00122 extern TARGET startpoint;
00123
00125 extern TARGET current_position;
00126
00127
00128
00129
00130
00131 uint32_t approx_distance( uint32_t dx, uint32_t dy ) __attribute__ ((hot));
00132 uint32_t approx_distance_3( uint32_t dx, uint32_t dy, uint32_t dz ) __attribute__ ((hot));
00133
00134
00135 const uint8_t msbloc (uint32_t v) __attribute__ ((const));
00136
00137
00138 void dda_create(DDA *dda, TARGET *target);
00139
00140
00141 void dda_start(DDA *dda) __attribute__ ((hot));
00142
00143
00144 void dda_step(DDA *dda) __attribute__ ((hot));
00145
00146 #endif