-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
Crazyflie drivers #9462
Merged
Merged
Crazyflie drivers #9462
Changes from 25 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
0cda469
created new distance sensor driver for vl53lxx
dpettenuzzo 0d6d828
vl53lxx driver: change to I2C4 on fmu-v5 (I2C connector)
827718b
created driver for pmw3901 optical flow module
1e879b4
added path to pmw3901 driver for fmu-v4pro cmake file
ce002c7
pmw3901 driver: fixed communication with sensor
fb23eae
pmw3901 driver: added integrator
a069248
vl53lxx driver: cleanup for pull request
8ada531
pmw3901 driver: cleanup for pull request
f5fea91
rcS: start vl53lxx and pmw3901 drivers
271317b
pmw3901 driver: multiply output of integrator by a constant to match …
250851b
vl53lxx driver: added work queue between measure and collect
cfa2ab7
vl53lxx driver: add saturation when distance goes beyond max_distance
d606d53
pmw3901 driver: remove integrator and publish data at sampling rate (…
919b086
vl53lxx and pmw3901 drivers: style fix
c55cbe9
crazyflie: add spi expansion to board configurations (modify spi bus …
74150f7
vl53lxx driver: change I2C frequency to 400 kHz
ab82a7b
nuttx_crazyflie_default.cmake: add vl53lxx driver, pmw3901 driver and…
60fba8d
crazyflie: support for sd card board via SPI
6a49d3c
pmw3901 driver: lock bus during transfers (avoid conflicts with sd ca…
76e2b6e
crazyflie: increase imu reading rate
7e45114
crazyflie: removed crazyflie specific #ifdefs from mpu9250
bc3eba4
crazyflie: add probe() to vl53lxx driver and set imu sampling rate to…
37355dc
crazyflie: optical flow and distace sensor driver fixes
33164bc
mpu9250: decrease sampling rate when using i2c
23aebf6
mpu9250: remove define from integrator interval when using i2c
913abc9
crazyflie: add downsampling to pwm3901 optflow driver
1af47ef
crazyflie: clean up
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ | |
px4_add_library(drivers_board | ||
init.c | ||
led.c | ||
spi.c | ||
timer_config.c | ||
usb.c | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
/************************************************************************************ | ||
* Included Files | ||
************************************************************************************/ | ||
|
||
#include <px4_config.h> | ||
#include <px4_log.h> | ||
|
||
#include <stdint.h> | ||
#include <stdbool.h> | ||
#include <debug.h> | ||
#include <unistd.h> | ||
|
||
#include <nuttx/spi/spi.h> | ||
#include <arch/board/board.h> | ||
#include <systemlib/px4_macros.h> | ||
#include <nuttx/mmcsd.h> | ||
|
||
#include <up_arch.h> | ||
#include <chip.h> | ||
#include <stm32_gpio.h> | ||
#include "board_config.h" | ||
#include <systemlib/err.h> | ||
|
||
/**************************************************************************** | ||
* Pre-Processor Definitions | ||
****************************************************************************/ | ||
|
||
/* Configuration ************************************************************/ | ||
|
||
/* Debug ********************************************************************/ | ||
|
||
/* Define CS GPIO array */ | ||
static const uint32_t spi1selects_gpio[] = PX4_FLOW_BUS_CS_GPIO; | ||
|
||
|
||
/************************************************************************************ | ||
* Public Functions | ||
************************************************************************************/ | ||
|
||
/************************************************************************************ | ||
* Name: stm32_spiinitialize | ||
* | ||
* Description: | ||
* Called to configure SPI chip select GPIO pins for the PX4FMU board. | ||
* | ||
************************************************************************************/ | ||
|
||
__EXPORT void stm32_spiinitialize(void) | ||
{ | ||
#ifdef CONFIG_STM32_SPI1 | ||
board_gpio_init(spi1selects_gpio, arraySize(spi1selects_gpio)); | ||
#endif | ||
|
||
} | ||
|
||
/************************************************************************************ | ||
* Name: stm32_spi_bus_initialize | ||
* | ||
* Description: | ||
* Called to configure SPI buses on PX4FMU board. | ||
* | ||
************************************************************************************/ | ||
static struct spi_dev_s *spi_expansion; | ||
|
||
__EXPORT int stm32_spi_bus_initialize(void) | ||
{ | ||
/* Configure SPI-based devices */ | ||
|
||
/* Get the external SPI port */ | ||
spi_expansion = stm32_spibus_initialize(PX4_SPI_BUS_EXPANSION); | ||
|
||
if (!spi_expansion) { | ||
PX4_ERR("[boot] FAILED to initialize SPI port %d\n", PX4_SPI_BUS_EXPANSION); | ||
return -ENODEV; | ||
} | ||
|
||
#ifdef CONFIG_MMCSD | ||
int ret = mmcsd_spislotinitialize(CONFIG_NSH_MMCSDMINOR, CONFIG_NSH_MMCSDSLOTNO, spi_expansion); | ||
|
||
if (ret != OK) { | ||
PX4_ERR("[boot] FAILED to bind SPI port 1 to the MMCSD driver\n"); | ||
return -ENODEV; | ||
} | ||
|
||
#endif | ||
|
||
|
||
return OK; | ||
|
||
} | ||
|
||
/************************************************************************************ | ||
* Name: stm32_spi1select and stm32_spi1status | ||
* | ||
* Description: | ||
* Called by stm32 spi driver on bus 1. | ||
* | ||
************************************************************************************/ | ||
|
||
__EXPORT void stm32_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected) | ||
{ | ||
/* SPI select is active low, so write !selected to select the device */ | ||
|
||
int sel = (int) devid; | ||
|
||
/* Making sure the other peripherals are not selected */ | ||
|
||
for (size_t cs = 0; arraySize(spi1selects_gpio) > 1 && cs < arraySize(spi1selects_gpio); cs++) { | ||
if (spi1selects_gpio[cs] != 0) { | ||
stm32_gpiowrite(spi1selects_gpio[cs], 1); | ||
} | ||
} | ||
|
||
uint32_t gpio = spi1selects_gpio[PX4_SPI_DEV_ID(sel)]; | ||
|
||
if (gpio) { | ||
stm32_gpiowrite(gpio, !selected); | ||
} | ||
} | ||
|
||
__EXPORT uint8_t stm32_spi1status(FAR struct spi_dev_s *dev, uint32_t devid) | ||
{ | ||
return SPI_STATUS_PRESENT; | ||
} | ||
|
||
|
||
/************************************************************************************ | ||
* Name: board_spi_reset | ||
* | ||
* Description: | ||
* | ||
* | ||
************************************************************************************/ | ||
|
||
__EXPORT void board_spi_reset(int ms) | ||
{ | ||
/* disable SPI bus */ | ||
for (size_t cs = 0; arraySize(spi1selects_gpio) > 1 && cs < arraySize(spi1selects_gpio); cs++) { | ||
if (spi1selects_gpio[cs] != 0) { | ||
stm32_configgpio(_PIN_OFF(spi1selects_gpio[cs])); | ||
} | ||
} | ||
|
||
stm32_configgpio(GPIO_SPI1_SCK_OFF); | ||
stm32_configgpio(GPIO_SPI1_MISO_OFF); | ||
stm32_configgpio(GPIO_SPI1_MOSI_OFF); | ||
|
||
/* wait for the sensor rail to reach GND */ | ||
usleep(ms * 1000); | ||
warnx("reset done, %d ms", ms); | ||
|
||
/* wait a bit before starting SPI, different times didn't influence results */ | ||
usleep(100); | ||
|
||
/* reconfigure the SPI pins */ | ||
for (size_t cs = 0; arraySize(spi1selects_gpio) > 1 && cs < arraySize(spi1selects_gpio); cs++) { | ||
if (spi1selects_gpio[cs] != 0) { | ||
stm32_configgpio(spi1selects_gpio[cs]); | ||
} | ||
} | ||
|
||
stm32_configgpio(GPIO_SPI1_SCK); | ||
stm32_configgpio(GPIO_SPI1_MISO); | ||
stm32_configgpio(GPIO_SPI1_MOSI); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
px4_add_module( | ||
MODULE drivers__vl53lxx | ||
MAIN vl53lxx | ||
COMPILE_FLAGS | ||
-Wno-sign-compare | ||
SRCS | ||
vl53lxx.cpp | ||
DEPENDS | ||
platforms__common | ||
) | ||
# vim: set noet ft=cmake fenc=utf-8 ff=unix : |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove this?