Go to the documentation of this file.00001
00005 #ifndef _PINIO_H
00006 #define _PINIO_H
00007
00008 #include "config.h"
00009
00010 #ifndef X_INVERT_ENABLE
00011 #define X_INVERT_ENABLE 0
00012 #endif
00013
00014 #ifndef Y_INVERT_ENABLE
00015 #define Y_INVERT_ENABLE 0
00016 #endif
00017
00018 #ifndef Z_INVERT_ENABLE
00019 #define Z_INVERT_ENABLE 0
00020 #endif
00021
00022 #ifndef E_INVERT_ENABLE
00023 #define E_INVERT_ENABLE 0
00024 #endif
00025
00026 #ifndef STEPPER_ENABLE_INVERT
00027 #define STEPPER_ENABLE_INVERT 0
00028 #endif
00029
00030
00031
00032
00033
00034 #ifdef STEPPER_ENABLE_PIN
00035 #define power_on() do { WRITE(STEPPER_ENABLE_PIN, STEPPER_ENABLE_INVERT); SET_OUTPUT(STEPPER_ENABLE_PIN); } while (0)
00036 #elif defined PS_ON_PIN
00037 #define power_on() do { WRITE(PS_ON_PIN, 0); SET_OUTPUT(PS_ON_PIN); } while (0)
00038 #else
00039 #define power_on() do { } while (0)
00040 #endif
00041
00042 void power_off(void);
00043
00044
00045
00046
00047
00048 #define _x_step(st) WRITE(X_STEP_PIN, st)
00049 #define x_step() _x_step(1);
00050 #ifndef X_INVERT_DIR
00051 #define x_direction(dir) WRITE(X_DIR_PIN, dir)
00052 #else
00053 #define x_direction(dir) WRITE(X_DIR_PIN, dir^1)
00054 #endif
00055 #ifdef X_MIN_PIN
00056 #ifndef X_INVERT_MIN
00057 #define x_min() (READ(X_MIN_PIN)?1:0)
00058 #else
00059 #define x_min() (READ(X_MIN_PIN)?0:1)
00060 #endif
00061 #else
00062 #define x_min() (0)
00063 #endif
00064 #ifdef X_MAX_PIN
00065 #ifndef X_INVERT_MAX
00066 #define x_max() (READ(X_MAX_PIN)?1:0)
00067 #else
00068 #define x_max() (READ(X_MAX_PIN)?0:1)
00069 #endif
00070 #else
00071 #define x_max() (0)
00072 #endif
00073
00074
00075
00076
00077
00078 #define _y_step(st) WRITE(Y_STEP_PIN, st)
00079 #define y_step() _y_step(1);
00080 #ifndef Y_INVERT_DIR
00081 #define y_direction(dir) WRITE(Y_DIR_PIN, dir)
00082 #else
00083 #define y_direction(dir) WRITE(Y_DIR_PIN, dir^1)
00084 #endif
00085 #ifdef Y_MIN_PIN
00086 #ifndef Y_INVERT_MIN
00087 #define y_min() (READ(Y_MIN_PIN)?1:0)
00088 #else
00089 #define y_min() (READ(Y_MIN_PIN)?0:1)
00090 #endif
00091 #else
00092 #define y_min() (0)
00093 #endif
00094 #ifdef Y_MAX_PIN
00095 #ifndef Y_INVERT_MAX
00096 #define y_max() (READ(Y_MAX_PIN)?1:0)
00097 #else
00098 #define y_max() (READ(Y_MAX_PIN)?0:1)
00099 #endif
00100 #else
00101 #define y_max() (0)
00102 #endif
00103
00104
00105
00106
00107
00108 #if defined Z_STEP_PIN && defined Z_DIR_PIN
00109 #define _z_step(st) WRITE(Z_STEP_PIN, st)
00110 #define z_step() _z_step(1);
00111 #ifndef Z_INVERT_DIR
00112 #define z_direction(dir) WRITE(Z_DIR_PIN, dir)
00113 #else
00114 #define z_direction(dir) WRITE(Z_DIR_PIN, dir^1)
00115 #endif
00116 #else
00117 #define _z_step(x) do { } while (0)
00118 #define z_step() do { } while (0)
00119 #define z_direction(x) do { } while (0)
00120 #endif
00121 #ifdef Z_MIN_PIN
00122 #ifndef Z_INVERT_MIN
00123 #define z_min() (READ(Z_MIN_PIN)?1:0)
00124 #else
00125 #define z_min() (READ(Z_MIN_PIN)?0:1)
00126 #endif
00127 #else
00128 #define z_min() (0)
00129 #endif
00130 #ifdef Z_MAX_PIN
00131 #ifndef Z_INVERT_MAX
00132 #define z_max() (READ(Z_MAX_PIN)?1:0)
00133 #else
00134 #define z_max() (READ(Z_MAX_PIN)?0:1)
00135 #endif
00136 #else
00137 #define z_max() (0)
00138 #endif
00139
00140
00141
00142
00143
00144 #if defined E_STEP_PIN && defined E_DIR_PIN
00145 #define _e_step(st) WRITE(E_STEP_PIN, st)
00146 #define e_step() _e_step(1);
00147 #ifndef E_INVERT_DIR
00148 #define e_direction(dir) WRITE(E_DIR_PIN, dir)
00149 #else
00150 #define e_direction(dir) WRITE(E_DIR_PIN, dir^1)
00151 #endif
00152 #else
00153 #define _e_step(st) do { } while (0)
00154 #define e_step() do { } while (0)
00155 #define e_direction(dir) do { } while (0)
00156 #endif
00157
00158
00159
00160
00161
00162
00163 #define unstep() do { _x_step(0); _y_step(0); _z_step(0); _e_step(0); } while (0)
00164
00165
00166
00167
00168
00169 #ifdef X_ENABLE_PIN
00170 #define x_enable() do { WRITE(X_ENABLE_PIN, X_INVERT_ENABLE); SET_OUTPUT(X_ENABLE_PIN); } while (0)
00171 #define x_disable() do { WRITE(X_ENABLE_PIN, X_INVERT_ENABLE ^ 1); SET_OUTPUT(X_ENABLE_PIN); } while (0)
00172 #else
00173 #define x_enable() do { } while (0)
00174 #define x_disable() do { } while (0)
00175 #endif
00176
00177 #ifdef Y_ENABLE_PIN
00178 #define y_enable() do { WRITE(Y_ENABLE_PIN, Y_INVERT_ENABLE); SET_OUTPUT(Y_ENABLE_PIN); } while (0)
00179 #define y_disable() do { WRITE(Y_ENABLE_PIN, Y_INVERT_ENABLE ^ 1); SET_OUTPUT(Y_ENABLE_PIN); } while (0)
00180 #else
00181 #define y_enable() do { } while (0)
00182 #define y_disable() do { } while (0)
00183 #endif
00184
00185 #ifdef Z_ENABLE_PIN
00186 #define z_enable() do { WRITE(Z_ENABLE_PIN, Z_INVERT_ENABLE); SET_OUTPUT(Z_ENABLE_PIN); } while (0)
00187 #define z_disable() do { WRITE(Z_ENABLE_PIN, Z_INVERT_ENABLE ^ 1); SET_OUTPUT(Z_ENABLE_PIN); } while (0)
00188 #else
00189 #define z_enable() do { } while (0)
00190 #define z_disable() do { } while (0)
00191 #endif
00192
00193 #ifdef E_ENABLE_PIN
00194 #define e_enable() do { WRITE(E_ENABLE_PIN, E_INVERT_ENABLE); SET_OUTPUT(E_ENABLE_PIN); } while (0)
00195 #define e_disable() do { WRITE(E_ENABLE_PIN, E_INVERT_ENABLE ^ 1); SET_OUTPUT(E_ENABLE_PIN); } while (0)
00196 #else
00197 #define e_enable() do { } while (0)
00198 #define e_disable() do { } while (0)
00199 #endif
00200
00201 #endif