Custom sensor connection

Firmware/software/electronics/mechanics
Post Reply
hjbyun
Beginner
Posts: 1
Joined: Tue Feb 16, 2021 1:39 am

Custom sensor connection

Post by hjbyun »

Hi! I'm newbie in crazyflie platform.

Recently, I got my own cf 2.0 and tried myself to connect cf with custom sensor that has 3 pins(Rx, Tx, Gnd). My goal is to log the data from sensor via cf with UART communication. So, I tried to connect sensor Tx to cf UART1 Rx, Gnd to cf UART1 Tx (b/c the sensor actually receives no signal). Also I customized the uart1test.c in the crazyflie-firmware to merely check if the sensor data is retrieved to my laptop. Unfortunately, I did not get any logs from cf and I wonder if I did write the code properly. Here is my temporary code for debugging (I set my cf in debug mode by following the documentation about writing my own custom deck).

Code: Select all

#define DEBUG_MODULE "U1T"

#include <stdint.h>
#include <string.h>

#include "FreeRTOS.h"
#include "task.h"

#include "stm32fxxx.h"
#include "system.h"
#include "config.h"
#include "debug.h"
#include "deck.h"
#include "uart1.h"
#include "log.h"

//Hardware configuration
static bool isInit;
static uint32_t testData

void uart1testTask(void* arg);

static void uart1testInit(DeckInfo *info)
{
  if(isInit)
    return;

  uart1Init(115200);

  xTaskCreate(uart1testTask, UART1_TEST_TASK_NAME, configMINIMAL_STACK_SIZE, NULL, UART1_TEST_TASK_PRI, NULL);

  isInit = true;
}

static bool uart1testTest()
{
  bool status = true;

  if(!isInit)
    return false;

  return status;
}

void uart1testTask(void* arg)
{
  systemWaitStart();

  while (1)
  {
    char c;
    uart1Getchar(&c);
    consolePutchar(c);
    testData = c;
  }
}

static const DeckDriver uart1test_deck = {
//  .vid = 0xBC,
//  .pid = 0x08,
  .name = "bcUart1Test",

  .usedPeriph = 0,
  .usedGpio = 0,
  .init = uart1testInit,
  .test = uart1testTest,
};

DECK_DRIVER(uart1test_deck);

LOG_GROUP_START(test)
LOG_ADD(LOG_UINT32, chR, &testData)
LOG_GROUP_STOP(test)
Thanks in advance!!
wydmynd
Member
Posts: 87
Joined: Thu Dec 06, 2018 9:25 am

Re: Custom sensor connection

Post by wydmynd »

did you compile the firmware using DDECK_FORCE flag to force it to compile your virtual deck? see the tutorials if not.
also, I recommend posting the output from the console (self test results)
Post Reply