mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-06-29 05:10:35 +08:00
crazyflie: support for sd card board via SPI
This commit is contained in:
committed by
Beat Küng
parent
818a6759d4
commit
b822966e8e
@@ -111,9 +111,9 @@
|
||||
#define PX4_SPI_BUS_EXPANSION 1
|
||||
|
||||
/* SPI1 CS */
|
||||
#define GPIO_SPI1_CS0_EXT /* PC12 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN12)
|
||||
#define GPIO_SPI1_CS1_EXT /* PB4 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN4)
|
||||
#define GPIO_SPI1_CS2_EXT /* PB5 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN5)
|
||||
#define GPIO_SPI1_CS0_EXT /* PC12 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN12)
|
||||
#define GPIO_SPI1_CS1_EXT /* PB4 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN4)
|
||||
#define GPIO_SPI1_CS2_EXT /* PB5 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTB|GPIO_PIN5)
|
||||
|
||||
#define PX4_FLOW_BUS_CS_GPIO { GPIO_SPI1_CS0_EXT, GPIO_SPI1_CS1_EXT, GPIO_SPI1_CS2_EXT }
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#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>
|
||||
@@ -20,6 +21,8 @@
|
||||
#include "board_config.h"
|
||||
#include <systemlib/err.h>
|
||||
|
||||
//#include "stm32.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
@@ -65,8 +68,7 @@ __EXPORT int stm32_spi_bus_initialize(void)
|
||||
{
|
||||
/* Configure SPI-based devices */
|
||||
|
||||
/* Get the SPI port for the Sensors */
|
||||
|
||||
/* Get the external SPI port */
|
||||
spi_expansion = stm32_spibus_initialize(PX4_SPI_BUS_EXPANSION);
|
||||
|
||||
if (!spi_expansion) {
|
||||
@@ -74,16 +76,17 @@ __EXPORT int stm32_spi_bus_initialize(void)
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Default PX4_SPI_BUS_SENSORS to 1MHz and de-assert the known chip selects. */
|
||||
//#ifdef CONFIG_MMCSD
|
||||
int ret = mmcsd_spislotinitialize(CONFIG_NSH_MMCSDMINOR, CONFIG_NSH_MMCSDSLOTNO, spi_expansion);
|
||||
|
||||
SPI_SETFREQUENCY(spi_expansion, 10000000);
|
||||
SPI_SETBITS(spi_expansion, 8);
|
||||
SPI_SETMODE(spi_expansion, SPIDEV_MODE3);
|
||||
|
||||
for (int cs = PX4_FLOW_BUS_FIRST_CS; cs <= PX4_FLOW_BUS_LAST_CS; cs++) {
|
||||
SPI_SELECT(spi_expansion, cs, false);
|
||||
if (ret != OK) {
|
||||
//message("[boot] FAILED to bind SPI port 1 to the MMCSD driver\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
//#endif
|
||||
|
||||
|
||||
return OK;
|
||||
|
||||
}
|
||||
@@ -101,7 +104,7 @@ __EXPORT void stm32_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, bool s
|
||||
/* SPI select is active low, so write !selected to select the device */
|
||||
|
||||
int sel = (int) devid;
|
||||
ASSERT(PX4_SPI_BUS_ID(sel) == PX4_SPI_BUS_EXPANSION);
|
||||
//ASSERT(PX4_SPI_BUS_ID(sel) == PX4_SPI_BUS_EXPANSION);
|
||||
|
||||
/* Making sure the other peripherals are not selected */
|
||||
|
||||
|
||||
@@ -77,8 +77,13 @@
|
||||
#include <board_config.h>
|
||||
|
||||
/* Configuration Constants */
|
||||
#ifdef PX4_SPI_BUS_EXPANSION
|
||||
#define PMW3901_BUS PX4_SPI_BUS_EXPANSION /* fmu-v4pro: PX4_SPI_BUS_EXT1 | fmu-v5: PX4_SPI_BUS_EXTERNAL1 */
|
||||
#endif
|
||||
|
||||
#ifdef PX4_SPIDEV_EXPANSION_2
|
||||
#define PMW3901_SPIDEV PX4_SPIDEV_EXPANSION_2 /* fmu-v4pro: PX4_SPIDEV_EXT0 | fmu-v5: PX4_SPIDEV_EXTERNAL1_1 */
|
||||
#endif
|
||||
|
||||
#define PMW3901_SPI_BUS_SPEED (2000000L) // 2MHz
|
||||
|
||||
|
||||
Reference in New Issue
Block a user