forked from triffid/FiveD_on_Arduino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpinio.h
168 lines (144 loc) · 3.84 KB
/
pinio.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#ifndef _PINIO_H
#define _PINIO_H
#include "config.h"
#ifndef X_INVERT_DIR
#define X_INVERT_DIR 0
#endif
#ifndef X_INVERT_MIN
#define X_INVERT_MIN 0
#endif
#ifndef X_INVERT_MAX
#define X_INVERT_MAX 0
#endif
#ifndef X_INVERT_ENABLE
#define X_INVERT_ENABLE 0
#endif
#ifndef Y_INVERT_DIR
#define Y_INVERT_DIR 0
#endif
#ifndef Y_INVERT_MIN
#define Y_INVERT_MIN 0
#endif
#ifndef Y_INVERT_MAX
#define Y_INVERT_MAX 0
#endif
#ifndef Y_INVERT_ENABLE
#define Y_INVERT_ENABLE 0
#endif
#ifndef Z_INVERT_DIR
#define Z_INVERT_DIR 0
#endif
#ifndef Z_INVERT_MIN
#define Z_INVERT_MIN 0
#endif
#ifndef Z_INVERT_MAX
#define Z_INVERT_MAX 0
#endif
#ifndef Z_INVERT_ENABLE
#define Z_INVERT_ENABLE 0
#endif
#ifndef E_INVERT_DIR
#define E_INVERT_DIR 0
#endif
#ifndef STEPPER_ENABLE_INVERT
#define STEPPER_ENABLE_INVERT 0
#endif
/*
Power
*/
#ifdef STEPPER_ENABLE_PIN
#define power_on() do { WRITE(STEPPER_ENABLE_PIN, STEPPER_ENABLE_INVERT); SET_OUTPUT(STEPPER_ENABLE_PIN); } while (0)
#elif defined PS_ON_PIN
#define power_on() do { WRITE(PS_ON_PIN, 0); SET_OUTPUT(PS_ON_PIN); } while (0)
#else
#define power_on() do { } while (0)
#endif
void power_off(void);
/*
X Stepper
*/
#define _x_step(st) WRITE(X_STEP_PIN, st)
#define x_step() _x_step(1);
#define x_direction(dir) WRITE(X_DIR_PIN, dir ^ X_INVERT_DIR)
#ifdef X_MIN_PIN
#define x_min() (READ(X_MIN_PIN)?(X_INVERT_MIN ^ 1):X_INVERT_MIN)
#else
#define x_min() (0)
#endif
#ifdef X_MAX_PIN
#define x_max() (READ(X_MAX_PIN)?(X_INVERT_MAX ^ 1):X_INVERT_MAX)
#else
#define x_max() (0)
#endif
/*
Y Stepper
*/
#define _y_step(st) WRITE(Y_STEP_PIN, st)
#define y_step() _y_step(1);
#define y_direction(dir) WRITE(Y_DIR_PIN, dir ^ Y_INVERT_DIR)
#ifdef Y_MIN_PIN
#define y_min() (READ(Y_MIN_PIN)?(Y_INVERT_MIN ^ 1):Y_INVERT_MIN)
#else
#define y_min() (0)
#endif
#ifdef Y_MAX_PIN
#define y_max() (READ(Y_MAX_PIN)?(Y_INVERT_MAX ^ 1):Y_INVERT_MAX)
#else
#define y_max() (0)
#endif
/*
Z Stepper
*/
#define _z_step(st) WRITE(Z_STEP_PIN, st)
#define z_step() _z_step(1);
#define z_direction(dir) WRITE(Z_DIR_PIN, dir ^ Z_INVERT_DIR)
#ifdef Z_MIN_PIN
#define z_min() (READ(Z_MIN_PIN)?(Z_INVERT_MIN ^ 1):Z_INVERT_MIN)
#else
#define z_min() (0)
#endif
#ifdef Z_MAX_PIN
#define z_max() (READ(Z_MAX_PIN)?(Z_INVERT_MAX ^ 1):Z_INVERT_MAX)
#else
#define z_max() (0)
#endif
/*
Extruder
*/
#define _e_step(st) WRITE(E_STEP_PIN, st)
#define e_step() _e_step(1);
#define e_direction(dir) WRITE(E_DIR_PIN, dir ^ E_INVERT_DIR)
/*
End Step - All Steppers
(so we don't have to delay in interrupt context)
*/
#ifndef DC_EXTRUDER
#define unstep() do { _x_step(0); _y_step(0); _z_step(0); _e_step(0); } while (0)
#else
#define unstep() do { _x_step(0); _y_step(0); _z_step(0); } while (0)
#endif
/*
Stepper Enable Pins
*/
#ifdef X_ENABLE_PIN
#define x_enable() do { WRITE(X_ENABLE_PIN, X_INVERT_ENABLE); SET_OUTPUT(X_ENABLE_PIN); } while (0)
#define x_disable() do { WRITE(X_ENABLE_PIN, X_INVERT_ENABLE ^ 1); SET_OUTPUT(X_ENABLE_PIN); } while (0)
#else
#define x_enable() do { } while (0)
#define x_disable() do { } while (0)
#endif
#ifdef Y_ENABLE_PIN
#define y_enable() do { WRITE(Y_ENABLE_PIN, Y_INVERT_ENABLE); SET_OUTPUT(Y_ENABLE_PIN); } while (0)
#define y_disable() do { WRITE(Y_ENABLE_PIN, Y_INVERT_ENABLE ^ 1); SET_OUTPUT(Y_ENABLE_PIN); } while (0)
#else
#define y_enable() do { } while (0)
#define y_disable() do { } while (0)
#endif
#ifdef Z_ENABLE_PIN
#define z_enable() do { WRITE(Z_ENABLE_PIN, Z_INVERT_ENABLE); SET_OUTPUT(Z_ENABLE_PIN); } while (0)
#define z_disable() do { WRITE(Z_ENABLE_PIN, Z_INVERT_ENABLE ^ 1); SET_OUTPUT(Z_ENABLE_PIN); } while (0)
#else
#define z_enable() do { } while (0)
#define z_disable() do { } while (0)
#endif
#endif /* _PINIO_H */