Skip to content

Commit

Permalink
Merge pull request #1380 from IMRCLab/bugfix_log_motor_type
Browse files Browse the repository at this point in the history
Motors: unify types for PWM to be uint16_t
  • Loading branch information
ataffanel authored Oct 7, 2024
2 parents b1a4a00 + c82b64b commit 0eda02a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/drivers/interface/motors.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,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
Expand Down
12 changes: 6 additions & 6 deletions src/drivers/src/motors.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -593,7 +593,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);

Expand Down Expand Up @@ -749,17 +749,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)

0 comments on commit 0eda02a

Please sign in to comment.