hw_stepper.h
Go to the documentation of this file.00001
00041 #ifndef HW_STEPPER_H
00042 #define HW_STEPPER_H
00043
00044 #include <hw/hw_cpufreq.h>
00045
00046 #include <cfg/macros.h>
00047
00048 #include <drv/timer.h>
00049
00050 #warning TODO:This is an example implentation, you must implement it!
00051
00052 #define STEPPER_STROBE_INIT \
00053 do { \
00054 \
00055 } while (0)
00056
00057
00058 #define STEPPER_STROBE_ON do { } while(0)
00059 #define STEPPER_STROBE_OFF do { } while(0)
00060
00065 #define STEPPER_PRESCALER_LOG2 1
00066
00070 #define STEPPER_CLOCK ((CPU_FREQ) >> STEPPER_PRESCALER_LOG2)
00071
00077 #define STEPPER_RESET_DELAY 1
00078
00079
00080
00081
00082 #define STEPPER_1_CW_CCW_PIN 0
00083 #define STEPPER_1_HALF_FULL_PIN 0
00084 #define STEPPER_1_CONTROL_PIN 0
00085 #define STEPPER_1_ENABLE_PIN 0
00086 #define STEPPER_1_RESET_PIN 0
00087
00088
00089
00090 #define STEPPER_1_SET do { } while(0)
00091
00092
00093 #define STEPPER_1_CLEAR do { } while(0)
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 #define STEPPER_PIN_INIT_MACRO(port, index) do { \
00104 \
00105 } while (0)
00106
00107
00108
00109
00110 #define STEPPER_SET_CW(index) do { } while (0)
00111 #define STEPPER_SET_CCW(index) do { } while (0)
00112 #define STEPPER_SET_HALF(index) do { } while (0)
00113 #define STEPPER_SET_FULL(index) do { } while (0)
00114 #define STEPPER_SET_CONTROL_LOW(index) do { } while (0)
00115 #define STEPPER_SET_CONTROL_HIGHT(index) do { } while (0)
00116 #define STEPPER_SET_ENABLE(index) do { } while (0)
00117 #define STEPPER_SET_DISABLE(index) do { } while (0)
00118 #define STEPPER_SET_RESET_ENABLE(index) do { } while (0)
00119 #define STEPPER_SET_RESET_DISABLE(index) do { } while (0)
00120
00121
00122
00123
00124
00125
00126 #define STEPPER_RESET_MACRO(index) do { \
00127 STEPPER_SET_RESET_ENABLE(index); \
00128 timer_udelay(STEPPER_RESET_DELAY); \
00129 STEPPER_SET_RESET_DISABLE(index); \
00130 } while (0)
00131
00132
00133
00134
00135 #define STEPPER_SET_STEP_MODE_MACRO(index, flag) do { \
00136 if (flag) \
00137 STEPPER_SET_HALF(index); \
00138 else \
00139 STEPPER_SET_FULL(index); \
00140 } while (0)
00141
00142
00143
00144
00145 #warning TODO: This macro is not implemented (see below)
00146
00147 #define STEPPER_SET_CONTROL_BIT_MACRO(index, flag) do { \
00148 \
00149 \
00150 \
00151 \
00152 } while (0)
00153
00154
00155
00156
00157 #warning TODO: This macro is not implemented (see below)
00158
00159 #define STEPPER_SET_POWER_CURRENT_MACRO(index, flag) do { \
00160 \
00161 \
00162 \
00163 \
00164 } while (0)
00165
00166
00167
00168
00169
00170
00171
00172
00173 #define STEPPER_SET_DIRECTION_MACRO(index, dir) do { \
00174 switch (dir) \
00175 { \
00176 case 1: \
00177 STEPPER_SET_CW(index); \
00178 break; \
00179 case -1: \
00180 STEPPER_SET_CCW(index); \
00181 break; \
00182 case 0: \
00183 break; \
00184 } \
00185 } while (0)
00186
00187
00188
00189
00190
00191
00192 #define STEPPER_INIT() do { \
00193 STEPPER_PIN_INIT_MACRO(A, 1); \
00194 \
00195 } while (0)
00196
00197
00198
00199
00200
00201 #define STEPPER_ENABLE(index) do { \
00202 switch (index) \
00203 { \
00204 case 1: \
00205 STEPPER_SET_ENABLE(1); \
00206 break; \
00207 \
00208 } \
00209 } while (0)
00210
00211
00212
00213
00214 #define STEPPER_ENABLE_ALL() do { \
00215 STEPPER_SET_ENABLE(1); \
00216 \
00217 } while (0)
00218
00219
00220
00221
00222 #define STEPPER_DISABLE(index) do { \
00223 switch (index) \
00224 { \
00225 case 1: \
00226 STEPPER_SET_DISABLE(1); \
00227 break; \
00228 \
00229 } \
00230 } while (0)
00231
00232
00233
00234
00235 #define STEPPER_DISABLE_ALL() do { \
00236 STEPPER_SET_DISABLE(1); \
00237 \
00238 } while (0)
00239
00240
00241
00242
00243 #define STEPPER_RESET(index) do { \
00244 switch (index) \
00245 { \
00246 case 1: \
00247 STEPPER_RESET_MACRO(1); \
00248 break; \
00249 \
00250 } \
00251 } while (0)
00252
00253
00254
00255
00256 #define STEPPER_RESET_ALL() do { \
00257 STEPPER_RESET_MACRO(1) \
00258 \
00259 } while (0)
00260
00261
00262 #define STEPPER_SET_HALF_STEP(index, flag) do { \
00263 switch (index) \
00264 { \
00265 case 1: \
00266 STEPPER_SET_STEP_MODE_MACRO(1, flag); \
00267 break; \
00268 \
00269 } \
00270 } while (0)
00271
00272
00273
00274 #define STEPPER_SET_CONTROL_BIT(index, flag) do { \
00275 switch (index) \
00276 { \
00277 case 1: \
00278 STEPPER_SET_CONTROL_BIT_MACRO(1, flag); \
00279 break; \
00280 \
00281 } \
00282 } while (0)
00283
00284
00285
00286 #define STEPPER_SET_POWER_CURRENT(index, flag) do { \
00287 switch (index) \
00288 { \
00289 case 1: \
00290 STEPPER_SET_POWER_CURRENT_MACRO(1, flag); \
00291 break; \
00292 \
00293 } \
00294 } while (0)
00295
00296
00297 #define STEPPER_SET_DIRECTION(index, dir) do { \
00298 switch (index) \
00299 { \
00300 case 1: \
00301 STEPPER_SET_DIRECTION_MACRO(1, dir); \
00302 break; \
00303 \
00304 } \
00305 } while (0)
00306
00307 #endif
00308
00309