From e5eafd5c08a29662a13934e991527e057a4486a1 Mon Sep 17 00:00:00 2001 From: Wolfgang Hoenig Date: Wed, 29 May 2024 22:02:46 +0200 Subject: [PATCH 1/2] Log motor.{m1,m2,m3,m4}: change type from uint32->uint16 --- src/drivers/src/motors.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/drivers/src/motors.c b/src/drivers/src/motors.c index 4336153e1..1e03f7cf7 100644 --- a/src/drivers/src/motors.c +++ b/src/drivers/src/motors.c @@ -740,17 +740,17 @@ LOG_GROUP_START(motor) /** * @brief Motor power (PWM value) for M1 [0 - UINT16_MAX] */ -LOG_ADD_CORE(LOG_UINT32, m1, &motor_ratios[MOTOR_M1]) +LOG_ADD_CORE(LOG_UINT16, m1, &motor_ratios[MOTOR_M1]) /** * @brief Motor power (PWM value) for M2 [0 - UINT16_MAX] */ -LOG_ADD_CORE(LOG_UINT32, m2, &motor_ratios[MOTOR_M2]) +LOG_ADD_CORE(LOG_UINT16, m2, &motor_ratios[MOTOR_M2]) /** * @brief Motor power (PWM value) for M3 [0 - UINT16_MAX] */ -LOG_ADD_CORE(LOG_UINT32, m3, &motor_ratios[MOTOR_M3]) +LOG_ADD_CORE(LOG_UINT16, m3, &motor_ratios[MOTOR_M3]) /** * @brief Motor power (PWM value) for M4 [0 - UINT16_MAX] */ -LOG_ADD_CORE(LOG_UINT32, m4, &motor_ratios[MOTOR_M4]) +LOG_ADD_CORE(LOG_UINT16, m4, &motor_ratios[MOTOR_M4]) LOG_GROUP_STOP(motor) From c82b64be5aa3fbc669bf24a3ce81c9ec491a0be9 Mon Sep 17 00:00:00 2001 From: Wolfgang Hoenig Date: Wed, 29 May 2024 22:07:07 +0200 Subject: [PATCH 2/2] motorsGetRatio: match docstring and implementation --- src/drivers/interface/motors.h | 4 ++-- src/drivers/src/motors.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/drivers/interface/motors.h b/src/drivers/interface/motors.h index e480123dd..ce88259a2 100644 --- a/src/drivers/interface/motors.h +++ b/src/drivers/interface/motors.h @@ -322,9 +322,9 @@ void motorsBurstDshot(); void motorsSetRatio(uint32_t id, uint16_t ratio); /** - * Get the PWM ratio of the motor 'id'. Return -1 if wrong ID. + * Get the PWM ratio of the motor 'id'. */ -int motorsGetRatio(uint32_t id); +uint16_t motorsGetRatio(uint32_t id); /** * FreeRTOS Task to test the Motors driver diff --git a/src/drivers/src/motors.c b/src/drivers/src/motors.c index 1e03f7cf7..2f425736a 100644 --- a/src/drivers/src/motors.c +++ b/src/drivers/src/motors.c @@ -49,7 +49,7 @@ static uint8_t motorSetEnable = 0; static uint16_t motorPowerSet[] = {0, 0, 0, 0}; // user-requested PWM signals (overrides) -static uint32_t motor_ratios[] = {0, 0, 0, 0}; // actual PWM signals +static uint16_t motor_ratios[] = {0, 0, 0, 0}; // actual PWM signals #ifdef CONFIG_MOTORS_ESC_PROTOCOL_DSHOT static DMA_InitTypeDef DMA_InitStructureShare; @@ -584,7 +584,7 @@ int motorsESCIsLo(uint32_t id) return GPIO_ReadInputDataBit(motorMap[id]->gpioPort, motorMap[id]->gpioPin) == Bit_RESET; } -int motorsGetRatio(uint32_t id) +uint16_t motorsGetRatio(uint32_t id) { ASSERT(id < NBR_OF_MOTORS);