Skip to content

Commit

Permalink
Renamed multiranger variables from OA. #374
Browse files Browse the repository at this point in the history
  • Loading branch information
tobbeanton committed Oct 16, 2018
1 parent 52ecf3a commit 06d306b
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions src/deck/drivers/src/multiranger.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "deck.h"
#include "param.h"

#define DEBUG_MODULE "OA"
#define DEBUG_MODULE "MR"

#include "system.h"
#include "debug.h"
Expand All @@ -45,19 +45,19 @@
static bool isInit = false;
static bool isTested = false;

#define OA_PIN_UP PCA95X4_P0
#define OA_PIN_FRONT PCA95X4_P4
#define OA_PIN_BACK PCA95X4_P1
#define OA_PIN_LEFT PCA95X4_P6
#define OA_PIN_RIGHT PCA95X4_P2
#define MR_PIN_UP PCA95X4_P0
#define MR_PIN_FRONT PCA95X4_P4
#define MR_PIN_BACK PCA95X4_P1
#define MR_PIN_LEFT PCA95X4_P6
#define MR_PIN_RIGHT PCA95X4_P2

static VL53L1_Dev_t devFront;
static VL53L1_Dev_t devBack;
static VL53L1_Dev_t devUp;
static VL53L1_Dev_t devLeft;
static VL53L1_Dev_t devRight;

static uint16_t oaGetMeasurementAndRestart(VL53L1_Dev_t *dev)
static uint16_t mrGetMeasurementAndRestart(VL53L1_Dev_t *dev)
{
VL53L1_Error status = VL53L1_ERROR_NONE;
VL53L1_RangingMeasurementData_t rangingData;
Expand All @@ -80,7 +80,7 @@ static uint16_t oaGetMeasurementAndRestart(VL53L1_Dev_t *dev)
return range;
}

static void oaTask(void *param)
static void mrTask(void *param)
{
VL53L1_Error status = VL53L1_ERROR_NONE;

Expand All @@ -105,15 +105,15 @@ static void oaTask(void *param)
{
vTaskDelayUntil(&lastWakeTime, M2T(100));

rangeSet(rangeFront, oaGetMeasurementAndRestart(&devFront)/1000.0f);
rangeSet(rangeBack, oaGetMeasurementAndRestart(&devBack)/1000.0f);
rangeSet(rangeUp, oaGetMeasurementAndRestart(&devUp)/1000.0f);
rangeSet(rangeLeft, oaGetMeasurementAndRestart(&devLeft)/1000.0f);
rangeSet(rangeRight, oaGetMeasurementAndRestart(&devRight)/1000.0f);
rangeSet(rangeFront, mrGetMeasurementAndRestart(&devFront)/1000.0f);
rangeSet(rangeBack, mrGetMeasurementAndRestart(&devBack)/1000.0f);
rangeSet(rangeUp, mrGetMeasurementAndRestart(&devUp)/1000.0f);
rangeSet(rangeLeft, mrGetMeasurementAndRestart(&devLeft)/1000.0f);
rangeSet(rangeRight, mrGetMeasurementAndRestart(&devRight)/1000.0f);
}
}

static void oaInit()
static void mrInit()
{
if (isInit)
{
Expand All @@ -122,35 +122,35 @@ static void oaInit()

pca95x4Init();

pca95x4ConfigOutput(~(OA_PIN_UP |
OA_PIN_RIGHT |
OA_PIN_LEFT |
OA_PIN_FRONT |
OA_PIN_BACK));
pca95x4ConfigOutput(~(MR_PIN_UP |
MR_PIN_RIGHT |
MR_PIN_LEFT |
MR_PIN_FRONT |
MR_PIN_BACK));

pca95x4ClearOutput(OA_PIN_UP |
OA_PIN_RIGHT |
OA_PIN_LEFT |
OA_PIN_FRONT |
OA_PIN_BACK);
pca95x4ClearOutput(MR_PIN_UP |
MR_PIN_RIGHT |
MR_PIN_LEFT |
MR_PIN_FRONT |
MR_PIN_BACK);

isInit = true;

xTaskCreate(oaTask, "oa", 2 * configMINIMAL_STACK_SIZE, NULL,
/*priority*/ 3, NULL);
xTaskCreate(mrTask, MULTIRANGER_TASK_NAME, MULTIRANGER_TASK_STACKSIZE, NULL,
MULTIRANGER_TASK_PRI, NULL);
}

static bool oaTest()
static bool mrTest()
{
bool pass = isInit;

if (isTested)
{
DEBUG_PRINT("Cannot test OA deck a second time\n");
DEBUG_PRINT("Cannot test MR deck a second time\n");
return false;
}

pca95x4SetOutput(OA_PIN_FRONT);
pca95x4SetOutput(MR_PIN_FRONT);
if (vl53l1xInit(&devFront, I2C1_DEV))
{
DEBUG_PRINT("Init front sensor [OK]\n");
Expand All @@ -161,7 +161,7 @@ static bool oaTest()
pass = false;
}

pca95x4SetOutput(OA_PIN_BACK);
pca95x4SetOutput(MR_PIN_BACK);
if (vl53l1xInit(&devBack, I2C1_DEV))
{
DEBUG_PRINT("Init back sensor [OK]\n");
Expand All @@ -172,7 +172,7 @@ static bool oaTest()
pass = false;
}

pca95x4SetOutput(OA_PIN_UP);
pca95x4SetOutput(MR_PIN_UP);
if (vl53l1xInit(&devUp, I2C1_DEV))
{
DEBUG_PRINT("Init up sensor [OK]\n");
Expand All @@ -183,7 +183,7 @@ static bool oaTest()
pass = false;
}

pca95x4SetOutput(OA_PIN_LEFT);
pca95x4SetOutput(MR_PIN_LEFT);
if (vl53l1xInit(&devLeft, I2C1_DEV))
{
DEBUG_PRINT("Init left sensor [OK]\n");
Expand All @@ -194,7 +194,7 @@ static bool oaTest()
pass = false;
}

pca95x4SetOutput(OA_PIN_RIGHT);
pca95x4SetOutput(MR_PIN_RIGHT);
if (vl53l1xInit(&devRight, I2C1_DEV))
{
DEBUG_PRINT("Init right sensor [OK]\n");
Expand All @@ -217,8 +217,8 @@ static const DeckDriver multiranger_deck = {

.usedGpio = 0, // FIXME: set the used pins

.init = oaInit,
.test = oaTest,
.init = mrInit,
.test = mrTest,
};

DECK_DRIVER(multiranger_deck);
Expand Down

0 comments on commit 06d306b

Please sign in to comment.