-
I'm trying to make a custom deck driver for a hall effect sensor that communicates over I2C and running into issues. The driver was heavily inspired by the examples on https://www.bitcraze.io/2020/07/intro-to-autonomous-robotics-with-the-crazyflie/ and https://www.bitcraze.io/documentation/repository/crazyflie-firmware/master/development/howto/. When I add the .o file in the Kbuild file in src/deck/drivers/src/ and do Then after I flash it to the drone and check the console in the client, the following errors show: What am I doing wrong? Relevant images and code are below: Terminal after make clean && make with my driver not showing up: Driver Code: #define DEBUG_MODULE "whiskerDeck"
// Crazyflie system headers
#include "debug.h"
#include "i2cdev.h"
#include "deck.h"
#include "log.h"
#include "FreeRTOS.h"
#include "task.h"
#include "system.h"
// RTOS Stuff
#define WHISKER_TASK_STACKSIZE (7*configMINIMAL_STACK_SIZE)
#define WHISKER_TASK_NAME "WHISKER"
#define WHISKER_TASK_PRI 3
// variables
#define ADDRESS 0x35
#define DELAY 500
float x_flux;
float y_flux;
float z_flux;
static bool isInit;
void whiskerTask(void* arg);
static void whiskerInit()
{
if (isInit)
return;
DEBUG_PRINT("Initializing Whisker...\n");
i2cdevInit(I2C1_DEV);
xTaskCreate(whiskerTask,WHISKER_TASK_NAME, WHISKER_TASK_STACKSIZE, NULL, WHISKER_TASK_PRI, NULL)
isInit = true;
DEBUG_PRINT("Whisker initialization complete!\n";)
}
static bool whiskerTest()
{
DEBUG_PRINT("WhiskerDeck test\n");
return true;
}
void whiskerTask(void* arg)
{
// Read first 7 data bytes
uint8_t buf[7]
// Wait for system to start
systemWaitStart();
TickType_t xLastWakeTime;
// UPDATE FOR MY SENSOR
i2cdevWriteByte(I2C1_DEV, (uint8_t)ADDRESS, I2CDEV_NO_MEM_ADDR, (uint8_t)0b00100000);
xLastWakeTime = xTaskGetTickCount();
while (1) {
vTaskDelayUntil(&xLastWakeTime, M2T(120));
// Read seven bytes from the sensor
i2cdevRead(I2C1_DEV, (uint8_t)BH1750I2CAddr, 7, &magdata);
// Combine the seven bytes to get data
int16_t x_flux = (int16_t)((magdata[0] << 8) | (magdata[4] & 0x0F)) >> 4;
int16_t y_flux = (int16_t)((magdata[1] << 8) | ((magdata[4] & 0x0F) << 4)) >> 4;
int16_t z_flux = (int16_t)((magdata[2] << 8) | ((magdata[5] & 0x0F) << 4)) >> 4;
// DEBUG_PRINT("Light reading is: %f\n", intensity);
}
}
// (rename source file pls)
static const DeckDriver WhiskerDriver = {
.name = "mywhiskerDeck",
.init = whiskerInit,
.test = whiskerTest,
};
// Logging:
DECK_DRIVER(WhiskerDriver);
LOG_GROUP_START(Whisker)
LOG_ADD(LOG_FLOAT, x_flux, &x_flux)
LOG_ADD(LOG_FLOAT, y_flux, &y_flux)
LOG_ADD(LOG_FLOAT, z_flux, &z_flux)
LOG_GROUP_STOP(Whisker) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
What you are doing seems correct. Adding the deck driver the way you are doing it does (try to) compile the driver for me. The driver does not compile so your problem is that the build system does not even try to build your driver. Are you sure you have saved the |
Beta Was this translation helpful? Give feedback.
What you are doing seems correct. Adding the deck driver the way you are doing it does (try to) compile the driver for me. The driver does not compile so your problem is that the build system does not even try to build your driver.
Are you sure you have saved the
Kconfig
file? In your screenshot vscode shows that there is unsaved modification.