7extern TIM_HandleTypeDef htim1;
8static const uint32_t k_ch[4] = { TIM_CHANNEL_1, TIM_CHANNEL_2, TIM_CHANNEL_3, TIM_CHANNEL_4 };
17 for (
int i = 0; i < 4; ++i) {
18 __HAL_TIM_SET_COMPARE(&htim1, k_ch[i], 0);
19 (void)HAL_TIM_PWM_Start(&htim1, k_ch[i]);
33 for (
int i = 0; i < 4; ++i) {
34 float d =
s_armed ? duty[i] : 0.0f;
35 if (d < 0.0f) d = 0.0f;
36 if (d > 1.0f) d = 1.0f;
37 __HAL_TIM_SET_COMPARE(&htim1, k_ch[i], (uint32_t)(d * (
float)
MOTORS_PWM_TOP + 0.5f));
48 if (duty < 0.0f) duty = 0.0f;
49 if (duty > 0.2f) duty = 0.2f;
50 for (
int i = 0; i < 4; ++i) {
51 const float d = (motor == (uint8_t)(i + 1)) ? duty : 0.0f;
52 __HAL_TIM_SET_COMPARE(&htim1, k_ch[i], (uint32_t)(d * (
float)
MOTORS_PWM_TOP + 0.5f));
55 (void)motor; (void)duty;
void motors_set(const float duty[4])
0..1, saturated
void motors_arm(uint8_t armed)
disarmed: duty forced to 0
static volatile uint8_t s_armed
void motors_test(uint8_t motor, float duty)
MOTOR_TEST (props off, disarmed): motor 1..4 at duty, the others off; motor 0 = all off.
PWM for 4 brushed coreless motors (8520, 1S) - PREPARED, unused in phase 1.