ESPlane
  • Introduction
  • 语言/language
    • 中文
    • English
  • Operater Guide
    • 01 ESPlane Operater Get Started
    • 02 CFclient User Guid
    • 03 Calibration And Commissioning Methods
    • 04 Flight Mode Introduction
    • 05 Pid Tuning
    • 06 Multi-user Mode
    • 07 Load And Endurance Test
  • Developer Guide
    • 01 ESPlane Developer Get Started
    • 02 Code Architecture And Startup Process
    • 03 Sensor Angle Fusion
    • 04 Sensor Calibration
    • 05 Control System
    • 06 Gyro and Accelerometer MPU6050 Driver
    • 07 Laser Sensor Vl53l1x Driver
    • 08 Barometer MS5611 Driver
    • 09 Magnetic Compass HMC5883l Driver
    • 10 Brushed Motor Driver
    • 11 Optical Flow Sensor Pmw3901 Driver
    • 12 Variable Unified Management
    • 13 Crtp Protocol Introduction
    • 14 Crtp Protocol Library - Cflib
    • 15 Compatible With ESPilot APP
    • 16 Height-hold Mode Development
    • 17 Positon-hold Mode Development
  • Research on Crazyflie
    • 01 Crazyflie Project Preview
    • 02 Crazyflie Source Preview
    • 03 Crazyflie Code Modularization Method
    • Discussion On Private-Improvement Scheme
    • Private-1.0 Code Debug Record
    • Private-Research On Commercial Micro Drone Products
    • Well-Known Drone Open Source Solutions
  • ESP32 Development notes
    • ESP32 Chip Naming Rules
    • ESP32 Pin Resource Allocation And Usage Recommendations
    • 01 ESP32-Hardware Preparation-ESP32-DevKitC V2 board
    • 02 ESP32-Environment Setup-Compilation And Programming
    • 03 ESP-IDF-Directory Structure-Template Engineering Analysis Notes
    • 04 ESP32-Code Debugging-Summary Of Several Debugging Methods
    • 05 ESP32 Event Loop
    • 14 ESP32 SPI Use Memo
    • 15 ESP32 GPIO Use Memo
  • Reference
    • bitcraze.io
    • esp-idf-release-v3.3
由 GitBook 提供支持
在本页
  • 1. 单总线接口one wire
  • 2. Crazyflie工程挂载自定义驱动方法

这有帮助吗?

  1. Research on Crazyflie

03 Crazyflie Code Modularization Method

1. 单总线接口one wire

onewire(单总线)是DALLAS公司推出的外围串行扩展总线,传输时钟信号又传输数据,而且能够进行双向通信,具有节省I/O口线、资源结构简单、成本低廉、便于总线扩展和维护等诸多优点.常用到单总线的器件,一般是温度传感器,如DS18B20、DS2431.

2. Crazyflie工程挂载自定义驱动方法

Deck drivers(Crazyflie开发方向,未完成)

The Deck API allows to easily communicates with decks installed on the Crazyflie. The deck API is still in development, it will:

  • Enumerates installed Deck and initialize drivers (*pretty much

    done*)

  • Provides easy to use arduino-like API to access (started)

  • Optionally provides a task to run in (arduino-like setup and loop)

    (not started yet)

    Decks are enumerated automatically using a One Wire (OW) memory soldered on the deck PCB. The Deck driver API is using a declarative syntax to register deck drivers and initialize them when the proper deck is installed.

Minimal driver 启动流程

  • At startup the decks are enumerated and if a deck has the name

    \"meMyled\", it will be initialized.

  • Init is called on all initialized driver and then test is called.

  • The init and test functions are both optional (we have some board

    with only init and event some with only test). If absent just remove

    the .init or .test initialisation.

  • In this mode no task are created so to run some code at regular

    intervale the code needs to deal with freeRtos or with the other

    parts of the Crazyflie code.

Minimal driver 示例 Deck drivers are in the deck/driver/src folder.

1.Create this file named hello.c in the deck/driver/src folder:

#define DEBUG_MODULE "HelloDeck"
#include "debug.h"

#include "deck.h"


static void helloInit()
{
  DEBUG_PRINT("Hello Crazyflie 2.0 deck world!\n");
}

static bool helloTest()
{
  DEBUG_PRINT("Hello test passed!\n");
  return true;
}

static const DeckDriver helloDriver = {
  .name = "myHello",
  .init = helloInit,
  .test = helloTest,
};

DECK_DRIVER(helloDriver);

2.Add this to the Makefile, after the line # Decks:

PROJ_OBJ += hello.o

3.Enabling the driver Decks can have a memory that contains its name. In our case the hello driver would be initialised only when a deck identified as \"myHello\" is installed on the Crazyflie. For development purpose it is possible to force enabling a deck driver with a compile flag. To do so create the file tools/make/config.mk with the content:

CFLAGS += -DDECK_FORCE=myHello

DEBUG=1

DEBUG=1 allows to get more information from the Crazyflie console when it starts. Debug should not be enabled if you intend to fly the Crazyflie out of the lab (it disables the watchdog).

4.Compile, flash and run! The output will be similar to the following:

crazyflie-firmware$ make
(...)
  CC    hello.o
(...)
Crazyflie 2.0 build!
Build 44:61f3d878233d (2015.08.1-44) MODIFIED
Version extracted from git
Crazyloader build!
   text    data     bss     dec     hex filename
 130660    1636   29828  162124   2794c cf2.elf
rm version.c
crazyflie-firmware$ make cload
../crazyflie-clients-python/bin/cfloader flash cf2.bin stm32-fw
Restart the Crazyflie you want to bootload in the next
 10 seconds ...
 done!
Connected to bootloader on Crazyflie 2.0 (version=0x10)
Target info: nrf51 (0xFE)
Flash pages: 232 | Page size: 1024 | Buffer pages: 1 | Start page: 88
144 KBytes of flash available for firmware image.
Target info: stm32 (0xFF)
Flash pages: 1024 | Page size: 1024 | Buffer pages: 10 | Start page: 16
1008 KBytes of flash available for firmware image.

Flashing 1 of 1 to stm32 (fw): 161867 bytes (159 pages) ..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10..........10.........9
Reset in firmware mode ...
$

Now you can connect your Crazyflie with the client and see your driver in the console!

上一页02 Crazyflie Source Preview下一页Discussion On Private-Improvement Scheme

最后更新于5年前

这有帮助吗?

在这里插入图片描述