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