separate PCA9685 driver into a shared directory
This commit is contained in:
@@ -9,9 +9,9 @@ void DriverMotor_Init(drvMotor_t* motor)
|
||||
__HAL_TIM_MOE_ENABLE(motor->pwm.tim.htim);
|
||||
}
|
||||
else if (motor->pwm_src == PWM_SRC_PCA9685) {
|
||||
PCA9685_SetPWM(motor->pwm.pca.channel, 0, 0);
|
||||
PCA9685_SetPin(motor->in1_pca_channel, 0);
|
||||
PCA9685_SetPin(motor->in2_pca_channel, 0);
|
||||
PCA9685_SetPWM(PCA9685_ADDR_1, motor->pwm.pca.channel, 0, 0);
|
||||
PCA9685_SetPin(PCA9685_ADDR_1, motor->in1_pca_channel, 0);
|
||||
PCA9685_SetPin(PCA9685_ADDR_1, motor->in2_pca_channel, 0);
|
||||
}
|
||||
|
||||
motor->enabled = false;
|
||||
@@ -42,11 +42,11 @@ void DriverMotor_setDirection(drvMotor_t* motor, bool forward){
|
||||
}
|
||||
else if (motor->pwm_src == PWM_SRC_PCA9685) {
|
||||
if (forward) {
|
||||
PCA9685_SetPin(motor->in1_pca_channel, 1); // IN1 = HIGH
|
||||
PCA9685_SetPin(motor->in2_pca_channel, 0); // IN2 = LOW
|
||||
PCA9685_SetPin(PCA9685_ADDR_1, motor->in1_pca_channel, 1); // IN1 = HIGH
|
||||
PCA9685_SetPin(PCA9685_ADDR_1, motor->in2_pca_channel, 0); // IN2 = LOW
|
||||
} else {
|
||||
PCA9685_SetPin(motor->in1_pca_channel, 0); // IN1 = LOW
|
||||
PCA9685_SetPin(motor->in2_pca_channel, 1); // IN2 = HIGH
|
||||
PCA9685_SetPin(PCA9685_ADDR_1, motor->in1_pca_channel, 0); // IN1 = LOW
|
||||
PCA9685_SetPin(PCA9685_ADDR_1, motor->in2_pca_channel, 1); // IN2 = HIGH
|
||||
}
|
||||
|
||||
motor->last_forward = forward;
|
||||
@@ -67,7 +67,7 @@ void DriverMotor_setPwm(drvMotor_t* motor, uint16_t pwm)
|
||||
}
|
||||
else if (motor->pwm_src == PWM_SRC_PCA9685) {
|
||||
if (pwm > 4095) pwm = 4095;
|
||||
PCA9685_SetPWM(motor->pwm.pca.channel, 0, pwm);
|
||||
PCA9685_SetPWM(PCA9685_ADDR_1, motor->pwm.pca.channel, 0, pwm);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user