Skip to content

Remove the RPM test from the exp deck driver completely #1433

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

Merged
merged 2 commits into from
Nov 4, 2024
Merged
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
107 changes: 8 additions & 99 deletions src/deck/drivers/src/test/exptestCfBl.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,6 @@ typedef struct _etGpio {
char name[6];
} EtGpio;

typedef struct {
logVarId_t m1;
logVarId_t m2;
logVarId_t m3;
logVarId_t m4;
} motorRpmParams_t;

static EtGpio etGpioIn[ET_NBR_PINS] = {
{ET_GPIO_PORT_TX1, ET_GPIO_PIN_TX1, "TX1"},
Expand All @@ -101,8 +95,6 @@ static EtGpio etGpioIn[ET_NBR_PINS] = {

static bool isInit;
const DeckDriver *bcRpm = NULL;
static motorRpmParams_t motorRpm = {0};
static uint32_t rpmResult[4] = {0,0,0,0};

static void expCfBlTestInit(DeckInfo *info)
{
Expand All @@ -113,96 +105,20 @@ static void expCfBlTestInit(DeckInfo *info)

// Initialize the VL53L0 sensor using the zRanger deck driver
bcRpm = deckFindDriverByName("bcRpm");
motorsInit(platformConfigGetMotorMapping());
motorRpm.m1 = logGetVarId("rpm", "m1");
motorRpm.m2 = logGetVarId("rpm", "m2");
motorRpm.m3 = logGetVarId("rpm", "m3");
motorRpm.m4 = logGetVarId("rpm", "m4");
isInit = true;
}

static int getMotorRpm(uint16_t motorIdx)
{
uint16_t ret = 0xFF;
switch (motorIdx) {
case MOTOR_M1:
ret = logGetInt(motorRpm.m1);
break;

case MOTOR_M2:
ret = logGetInt(motorRpm.m2);
break;

case MOTOR_M3:
ret = logGetInt(motorRpm.m3);
break;

case MOTOR_M4:
ret = logGetInt(motorRpm.m4);
break;

default:
break;
}
return ret;
}

static void setMotorsPwm(uint32_t pwm)
{
for (int i = 0; i<NBR_OF_MOTORS; i++) {
motorsSetRatio(i, pwm);
if (bcRpm != NULL) {
isInit = true;
} else {
DEBUG_PRINT("bcRpm driver not found\n");
}
}

static void runMotors()
{
#ifdef CONFIG_MOTORS_ESC_PROTOCOL_DSHOT
motorsBurstDshot();
#endif
vTaskDelay(MOTOR_FEED_SIGNAL_INTVL);
}



static bool rpmTestRun(void)
{
uint16_t testTime = MOTOR_TEST_TIME_MILLIS;
int32_t waitTime = MOTOR_TEST_TIME_MILLIS;
uint32_t rpmSamples[] = {0,0,0,0};
setMotorsPwm(0);
while (waitTime) { //We need to wait until all ESCs are started. We need to feed a signal continuosly so they dont go to sleep
runMotors();
waitTime -= MOTOR_FEED_SIGNAL_INTVL;
}

setMotorsPwm(MOTOR_TEST_PWM);
while(testTime) {
runMotors();
testTime -= MOTOR_FEED_SIGNAL_INTVL;
for (int i = 0; i<NBR_OF_MOTORS; i++) {
rpmSamples[i] += getMotorRpm(i);
}
}

setMotorsPwm(0);
for (int i = 0; i<NBR_OF_MOTORS; i++) {
uint32_t rpmAvg = rpmSamples[i] / MOTOR_RPM_NBR_SAMPLES;
rpmResult[i] = rpmAvg;
}

return true; //Return True here regardless. This should be checked externally
}

static bool expCfBlTestRun(void)
{
int i;
volatile int delay;
bool status = true;
GPIO_InitTypeDef GPIO_InitStructure;
GpioRegBuf gpioSaved;

isInit = true;

status &= sensorsManufacturingTest();


Expand Down Expand Up @@ -246,13 +162,12 @@ static bool expCfBlTestRun(void)

decktestRestoreGPIOStatesABC(&gpioSaved);

//Run rpm test
if(status) {
if(status && isInit) {
if(bcRpm->init) {
bcRpm->init(NULL);
bcRpm->init(NULL);
} else {
status &= false;
}

status = rpmTestRun();
}
return status;
}
Expand All @@ -271,10 +186,4 @@ static const DeckDriver expCfBltest_deck = {
.test = expCfBlTestRun
};

PARAM_GROUP_START(prodTestRpm)
PARAM_ADD(PARAM_UINT32 | PARAM_RONLY, m1, &rpmResult[0])
PARAM_ADD(PARAM_UINT32 | PARAM_RONLY, m2, &rpmResult[1])
PARAM_ADD(PARAM_UINT32 | PARAM_RONLY, m3, &rpmResult[2])
PARAM_ADD(PARAM_UINT32 | PARAM_RONLY, m4, &rpmResult[3])
PARAM_GROUP_STOP(prodTestRpm)
DECK_DRIVER(expCfBltest_deck);