Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Motors: unify types for PWM to be uint16_t #1380

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/drivers/interface/motors.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 @@ -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);

Expand Down Expand Up @@ -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)
Loading