blob: ac303d0fca6dbf80d1e69583baa7e9ddffbe7eca (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
#include "avr.h"
#include "util.h"
void setMotorSpeed(MOTOR *motor, int speed) {
if(speed > 0) {
*motor->port &= ~motor->revMask;
*motor->port |= motor->fwdMask;
}
else if(speed < 0) {
*motor->port &= ~motor->fwdMask;
*motor->port |= motor->revMask;
}
else *motor->port |= motor->fwdMask|motor->revMask;
*motor->pwmPort = CLAMP(0, ABS(speed), 255);
}
|