Revision 1543
Added a bunch of debug prints to the library
motor.c | ||
---|---|---|
56 | 56 |
**/ |
57 | 57 |
int motors_init( void ) { |
58 | 58 |
|
59 |
if(motors_initd) |
|
59 |
if(motors_initd) { |
|
60 |
DRAGONFLY_DEBUG_PRINT("ERROR: motors already init'd\r\n"); |
|
60 | 61 |
return ERROR_INIT_ALREADY_INITD; |
62 |
} |
|
61 | 63 |
|
62 | 64 |
|
63 | 65 |
// Configure counter such that we use phase correct |
... | ... | |
92 | 94 |
* @see motor_r_set, motors_init |
93 | 95 |
**/ |
94 | 96 |
int motor_l_set(int direction, int speed) { |
95 |
if(!motors_initd) |
|
97 |
if(!motors_initd) { |
|
98 |
DRAGONFLY_DEBUG_PRINT("ERROR: motors not init'd\r\n"); |
|
96 | 99 |
return ERROR_LIBRARY_NOT_INITD; |
100 |
} |
|
97 | 101 |
|
98 | 102 |
if(direction == 0) { |
99 | 103 |
// turn off PWM first if switching directions |
... | ... | |
131 | 135 |
* @see motor_l_set, motors_init |
132 | 136 |
**/ |
133 | 137 |
int motor_r_set(int direction, int speed) { |
134 |
if(!motors_initd) |
|
138 |
if(!motors_initd) { |
|
139 |
DRAGONFLY_DEBUG_PRINT("ERROR: encoders not init'd\r\n"); |
|
135 | 140 |
return ERROR_LIBRARY_NOT_INITD; |
141 |
} |
|
136 | 142 |
|
137 | 143 |
if(direction == 0) { |
138 | 144 |
// PORTD |= 0x20; |
... | ... | |
198 | 204 |
* @see motors_init |
199 | 205 |
**/ |
200 | 206 |
int motors_off( void ) { |
201 |
if(!motors_initd) |
|
207 |
if(!motors_initd) { |
|
208 |
DRAGONFLY_DEBUG_PRINT("ERROR: encoders not init'd\r\n"); |
|
202 | 209 |
return ERROR_LIBRARY_NOT_INITD; |
210 |
} |
|
203 | 211 |
|
204 | 212 |
OCR1AL = 0x0; |
205 | 213 |
OCR1BL = 0x0; |
Also available in: Unified diff