Changes to px4fmu-v1 for upstream Nuttx

This commit is contained in:
David Sidrane
2016-12-12 13:32:39 -10:00
committed by Lorenz Meier
parent 64c00e6c95
commit 82cb9353d1
13 changed files with 843 additions and 338 deletions
@@ -1,5 +1,7 @@
include(nuttx/px4_impl_nuttx) include(nuttx/px4_impl_nuttx)
px4_nuttx_configure(HWCLASS m4 CONFIG nsh ROMFS y ROMFSROOT px4fmu_common)
set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake)
set(config_module_list set(config_module_list
+16 -4
View File
@@ -1,5 +1,5 @@
/************************************************************************************ /************************************************************************************
* configs/stm32f4discovery/include/board.h * nuttx-configs/px4fmu-v1/include/board.h
* include/arch/board/board.h * include/arch/board/board.h
* *
* Copyright (C) 2012 Gregory Nutt. All rights reserved. * Copyright (C) 2012 Gregory Nutt. All rights reserved.
@@ -150,11 +150,23 @@
/* Timer Frequencies, if APBx is set to 1, frequency is same to APBx /* Timer Frequencies, if APBx is set to 1, frequency is same to APBx
* otherwise frequency is 2xAPBx. * otherwise frequency is 2xAPBx.
* Note: TIM1,8 are on APB2, others on APB1 * Note: TIM1,8-11 are on APB2, others on APB1
*/ */
#define STM32_TIM18_FREQUENCY (2*STM32_PCLK2_FREQUENCY) #define BOARD_TIM1_FREQUENCY STM32_APB2_TIM1_CLKIN
#define STM32_TIM27_FREQUENCY (2*STM32_PCLK1_FREQUENCY) #define BOARD_TIM2_FREQUENCY STM32_APB1_TIM2_CLKIN
#define BOARD_TIM3_FREQUENCY STM32_APB1_TIM3_CLKIN
#define BOARD_TIM4_FREQUENCY STM32_APB1_TIM4_CLKIN
#define BOARD_TIM5_FREQUENCY STM32_APB1_TIM5_CLKIN
#define BOARD_TIM6_FREQUENCY STM32_APB1_TIM6_CLKIN
#define BOARD_TIM7_FREQUENCY STM32_APB1_TIM7_CLKIN
#define BOARD_TIM8_FREQUENCY STM32_APB2_TIM8_CLKIN
#define BOARD_TIM9_FREQUENCY STM32_APB2_TIM9_CLKIN
#define BOARD_TIM10_FREQUENCY STM32_APB2_TIM10_CLKIN
#define BOARD_TIM11_FREQUENCY STM32_APB2_TIM11_CLKIN
#define BOARD_TIM12_FREQUENCY STM32_APB1_TIM12_CLKIN
#define BOARD_TIM13_FREQUENCY STM32_APB1_TIM13_CLKIN
#define BOARD_TIM14_FREQUENCY STM32_APB1_TIM14_CLKIN
/* LED definitions ******************************************************************/ /* LED definitions ******************************************************************/
/* If CONFIG_ARCH_LEDS is not defined, then the user can control the LEDs in any /* If CONFIG_ARCH_LEDS is not defined, then the user can control the LEDs in any
+15 -11
View File
@@ -1,5 +1,5 @@
############################################################################ ############################################################################
# configs/px4fmu-v1/nsh/Make.defs # nuttx-configs/px4fmu-v1/nsh/Make.defs
# #
# Copyright (C) 2011 Gregory Nutt. All rights reserved. # Copyright (C) 2011 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org> # Author: Gregory Nutt <gnutt@nuttx.org>
@@ -35,14 +35,14 @@
include ${TOPDIR}/.config include ${TOPDIR}/.config
include ${TOPDIR}/tools/Config.mk include ${TOPDIR}/tools/Config.mk
include $(TOPDIR)/PX4_Warnings.mk include $(TOPDIR)/PX4_Warnings.mk
include $(TOPDIR)/PX4_Config.mk
# #
# We only support building with the ARM bare-metal toolchain from # We only support building with the ARM bare-metal toolchain from
# https://launchpad.net/gcc-arm-embedded on Windows, Linux or Mac OS. # https://launchpad.net/gcc-arm-embedded on Windows, Linux or Mac OS.
# #
CONFIG_ARMV7M_TOOLCHAIN := GNU_EABI CONFIG_ARMV7M_TOOLCHAIN := GNU_EABI${HOST_OS_FIRST_LETTER}
include ${TOPDIR}/arch/arm/src/armv7-m/Toolchain.defs include ${TOPDIR}/arch/arm/src/armv7-m/Toolchain.defs
@@ -62,17 +62,18 @@ ARCHCPUFLAGS = -mcpu=cortex-m4 \
-mfpu=fpv4-sp-d16 \ -mfpu=fpv4-sp-d16 \
-mfloat-abi=hard -mfloat-abi=hard
# Enable precise stack overflow tracking
# enable precise stack overflow tracking
ifeq ($(CONFIG_ARMV7M_STACKCHECK),y) ifeq ($(CONFIG_ARMV7M_STACKCHECK),y)
INSTRUMENTATIONDEFINES = -finstrument-functions -ffixed-r10 INSTRUMENTATIONDEFINES = -finstrument-functions -ffixed-r10
endif endif
# pull in *just* libm from the toolchain ... this is grody # Pull in *just* libm from the toolchain ... this is grody
LIBM = "${shell $(CC) $(ARCHCPUFLAGS) -print-file-name=libm.a}" LIBM = "${shell $(CC) $(ARCHCPUFLAGS) -print-file-name=libm.a}"
EXTRA_LIBS += $(LIBM) EXTRA_LIBS += $(LIBM)
# use our linker script # Use our linker script
LDSCRIPT = ld.script LDSCRIPT = ld.script
ifeq ($(WINTOOL),y) ifeq ($(WINTOOL),y)
@@ -94,18 +95,20 @@ else
ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT) ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)
else else
# Linux/Cygwin-native toolchain # Linux/Cygwin-native toolchain
MKDEP = $(TOPDIR)/tools/mkdeps.sh MKDEP = $(TOPDIR)/tools/mkdeps$(HOSTEXEEXT)
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx
ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT) ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)
endif endif
endif endif
# tool versions # Tool versions
ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'} ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'}
ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1} ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1}
# optimisation flags # Optimization flags
ARCHOPTIMIZATION = $(MAXOPTIMIZATION) \ ARCHOPTIMIZATION = $(MAXOPTIMIZATION) \
-fno-strict-aliasing \ -fno-strict-aliasing \
-fno-strength-reduce \ -fno-strength-reduce \
@@ -127,7 +130,8 @@ ARCHWARNINGSXX = $(ARCHWARNINGS) $(PX4_ARCHWARNINGSXX)
ARCHDEFINES = ARCHDEFINES =
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
# this seems to be the only way to add linker flags # This seems to be the only way to add linker flags
EXTRA_LIBS += --warn-common \ EXTRA_LIBS += --warn-common \
--gc-sections --gc-sections
@@ -146,8 +150,8 @@ OBJEXT = .o
LIBEXT = .a LIBEXT = .a
EXEEXT = EXEEXT =
# Produce partially-linked $1 from files in $2
# produce partially-linked $1 from files in $2
define PRELINK define PRELINK
@echo "PRELINK: $1" @echo "PRELINK: $1"
$(Q) $(LD) -Ur -o $1 $2 && $(OBJCOPY) --localize-hidden $1 $(Q) $(LD) -Ur -o $1 $2 && $(OBJCOPY) --localize-hidden $1
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# configs/px4fmu-v1/usbnsh/setenv.sh # nuttx-configs/px4fmu-v1/nsh/setenv.sh
# #
# Copyright (C) 2013 Gregory Nutt. All rights reserved. # Copyright (C) 2013 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org> # Author: Gregory Nutt <gnutt@nuttx.org>
+1 -1
View File
@@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* configs/px4fmu-v1/scripts/ld.script * nuttx-configs/px4fmu-v1/scripts/ld.script
* *
* Copyright (C) 2011 Gregory Nutt. All rights reserved. * Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
+4 -1
View File
@@ -1,5 +1,4 @@
############################################################################ ############################################################################
# configs/px4fmu-v1/src/Makefile
# #
# Copyright (C) 2013 Gregory Nutt. All rights reserved. # Copyright (C) 2013 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org> # Author: Gregory Nutt <gnutt@nuttx.org>
@@ -80,5 +79,9 @@ distclean: clean
$(call DELFILE, Make.dep) $(call DELFILE, Make.dep)
$(call DELFILE, .depend) $(call DELFILE, .depend)
ifneq ($(BOARD_CONTEXT),y)
context:
endif
-include Make.dep -include Make.dep
+1 -23
View File
@@ -46,9 +46,7 @@
#include <px4_config.h> #include <px4_config.h>
#include <nuttx/compiler.h> #include <nuttx/compiler.h>
#include <stdint.h> #include <stdint.h>
#include <nuttx/board.h>
#include <stm32.h>
#include <arch/board/board.h>
/**************************************************************************************************** /****************************************************************************************************
* Definitions * Definitions
@@ -57,7 +55,6 @@
/* PX4IO connection configuration */ /* PX4IO connection configuration */
#define PX4IO_SERIAL_DEVICE "/dev/ttyS2" #define PX4IO_SERIAL_DEVICE "/dev/ttyS2"
#define UDID_START 0x1FFF7A10
//#ifdef CONFIG_STM32_SPI2 //#ifdef CONFIG_STM32_SPI2
//# error "SPI2 is not supported on this board" //# error "SPI2 is not supported on this board"
@@ -252,25 +249,6 @@ extern void stm32_usbinitialize(void);
#define board_peripheral_reset(ms) #define board_peripheral_reset(ms)
/****************************************************************************
* Name: nsh_archinitialize
*
* Description:
* Perform architecture specific initialization for NSH.
*
* CONFIG_NSH_ARCHINIT=y :
* Called from the NSH library
*
* CONFIG_BOARD_INITIALIZE=y, CONFIG_NSH_LIBRARY=y, &&
* CONFIG_NSH_ARCHINIT=n :
* Called from board_initialize().
*
****************************************************************************/
#ifdef CONFIG_NSH_LIBRARY
int nsh_archinitialize(void);
#endif
#include "../common/board_common.h" #include "../common/board_common.h"
#endif /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */
+3 -18
View File
@@ -46,7 +46,7 @@
#include <errno.h> #include <errno.h>
#include <debug.h> #include <debug.h>
#include <nuttx/can.h> #include <nuttx/drivers/can.h>
#include <arch/board/board.h> #include <arch/board/board.h>
#include "chip.h" #include "chip.h"
@@ -74,21 +74,6 @@
# define CAN_PORT 2 # define CAN_PORT 2
#endif #endif
/* Debug ***************************************************************************/
/* Non-standard debug that may be enabled just for testing CAN */
#ifdef CONFIG_DEBUG_CAN
# define candbg dbg
# define canvdbg vdbg
# define canlldbg lldbg
# define canllvdbg llvdbg
#else
# define candbg(x...)
# define canvdbg(x...)
# define canlldbg(x...)
# define canllvdbg(x...)
#endif
/************************************************************************************ /************************************************************************************
* Private Functions * Private Functions
************************************************************************************/ ************************************************************************************/
@@ -120,7 +105,7 @@ int can_devinit(void)
can = stm32_caninitialize(CAN_PORT); can = stm32_caninitialize(CAN_PORT);
if (can == NULL) { if (can == NULL) {
candbg("ERROR: Failed to get CAN interface\n"); canerr("ERROR: Failed to get CAN interface\n");
return -ENODEV; return -ENODEV;
} }
@@ -129,7 +114,7 @@ int can_devinit(void)
ret = can_register("/dev/can0", can); ret = can_register("/dev/can0", can);
if (ret < 0) { if (ret < 0) {
candbg("ERROR: can_register failed: %d\n", ret); canerr("ERROR: can_register failed: %d\n", ret);
return ret; return ret;
} }
+57 -25
View File
@@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
* *
* Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved. * Copyright (c) 2012-2015 PX4 Development Team. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@@ -35,10 +35,10 @@
* @file px4fmu_init.c * @file px4fmu_init.c
* *
* PX4FMU-specific early startup code. This file implements the * PX4FMU-specific early startup code. This file implements the
* nsh_archinitialize() function that is called early by nsh during startup. * board_app_initialize() function that is called early by nsh during startup.
* *
* Code here is run before the rcS script is invoked; it should start required * Code here is run before the rcS script is invoked; it should start required
* subsystems and perform board-specific initialisation. * subsystems and perform board-specific initialization.
*/ */
/**************************************************************************** /****************************************************************************
@@ -53,8 +53,9 @@
#include <errno.h> #include <errno.h>
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include <nuttx/spi.h> #include <nuttx/board.h>
#include <nuttx/i2c.h> #include <nuttx/spi/spi.h>
#include <nuttx/i2c/i2c_master.h>
#include <nuttx/mmcsd.h> #include <nuttx/mmcsd.h>
#include <nuttx/analog/adc.h> #include <nuttx/analog/adc.h>
@@ -79,13 +80,13 @@
#ifdef CONFIG_CPP_HAVE_VARARGS #ifdef CONFIG_CPP_HAVE_VARARGS
# ifdef CONFIG_DEBUG # ifdef CONFIG_DEBUG
# define message(...) lowsyslog(__VA_ARGS__) # define message(...) syslog(__VA_ARGS__)
# else # else
# define message(...) printf(__VA_ARGS__) # define message(...) printf(__VA_ARGS__)
# endif # endif
#else #else
# ifdef CONFIG_DEBUG # ifdef CONFIG_DEBUG
# define message lowsyslog # define message syslog
# else # else
# define message printf # define message printf
# endif # endif
@@ -124,18 +125,39 @@ __END_DECLS
__EXPORT void stm32_boardinitialize(void) __EXPORT void stm32_boardinitialize(void)
{ {
/* configure always-on ADC pins */
stm32_configgpio(GPIO_ADC1_IN10);
stm32_configgpio(GPIO_ADC1_IN11);
/* configure SPI interfaces */ /* configure SPI interfaces */
stm32_spiinitialize(); stm32_spiinitialize();
/* configure LEDs (empty call to NuttX' ledinit) */ /* configure LEDs (empty call to NuttX' ) */
up_ledinit(); board_autoled_initialize();
} }
/**************************************************************************** /****************************************************************************
* Name: nsh_archinitialize * Name: board_app_initialize
* *
* Description: * Description:
* Perform architecture specific initialization * Perform application specific initialization. This function is never
* called directly from application code, but only indirectly via the
* (non-standard) boardctl() interface using the command BOARDIOC_INIT.
*
* Input Parameters:
* arg - The boardctl() argument is passed to the board_app_initialize()
* implementation without modification. The argument has no
* meaning to NuttX; the meaning of the argument is a contract
* between the board-specific initalization logic and the the
* matching application logic. The value cold be such things as a
* mode enumeration value, a set of DIP switch switch settings, a
* pointer to configuration data read from a file or serial FLASH,
* or whatever you would like to do with it. Every implementation
* should accept zero/NULL as a default configuration.
*
* Returned Value:
* Zero (OK) is returned on success; a negated errno value is returned on
* any failure to indicate the nature of the failure.
* *
****************************************************************************/ ****************************************************************************/
@@ -143,17 +165,27 @@ static struct spi_dev_s *spi1;
static struct spi_dev_s *spi2; static struct spi_dev_s *spi2;
static struct spi_dev_s *spi3; static struct spi_dev_s *spi3;
#include <math.h> __EXPORT int board_app_initialize(uintptr_t arg)
__EXPORT int nsh_archinitialize(void)
{ {
int result; int result;
/* configure always-on ADC pins */
px4_arch_configgpio(GPIO_ADC1_IN10);
px4_arch_configgpio(GPIO_ADC1_IN11);
/* IN12 and IN13 further below */ /* IN12 and IN13 further below */
#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE)
/* run C++ ctors before we go any further */
up_cxxinitialize();
# if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE)
# error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE.
# endif
#else
# error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined.
#endif
/* configure the high-resolution time/callout interface */ /* configure the high-resolution time/callout interface */
hrt_init(); hrt_init();
@@ -187,11 +219,11 @@ __EXPORT int nsh_archinitialize(void)
/* Configure SPI-based devices */ /* Configure SPI-based devices */
spi1 = px4_spibus_initialize(1); spi1 = stm32_spibus_initialize(1);
if (!spi1) { if (!spi1) {
message("[boot] FAILED to initialize SPI port 1\r\n"); message("[boot] FAILED to initialize SPI port 1\r\n");
up_ledon(LED_AMBER); board_autoled_on(LED_AMBER);
return -ENODEV; return -ENODEV;
} }
@@ -210,7 +242,7 @@ __EXPORT int nsh_archinitialize(void)
*/ */
#ifdef CONFIG_STM32_SPI2 #ifdef CONFIG_STM32_SPI2
spi2 = px4_spibus_initialize(2); spi2 = stm32_spibus_initialize(2);
/* Default SPI2 to 1MHz and de-assert the known chip selects. */ /* Default SPI2 to 1MHz and de-assert the known chip selects. */
SPI_SETFREQUENCY(spi2, 10000000); SPI_SETFREQUENCY(spi2, 10000000);
SPI_SETBITS(spi2, 8); SPI_SETBITS(spi2, 8);
@@ -223,17 +255,17 @@ __EXPORT int nsh_archinitialize(void)
spi2 = NULL; spi2 = NULL;
message("[boot] Enabling IN12/13 instead of SPI2\n"); message("[boot] Enabling IN12/13 instead of SPI2\n");
/* no SPI2, use pins for ADC */ /* no SPI2, use pins for ADC */
px4_arch_configgpio(GPIO_ADC1_IN12); stm32_configgpio(GPIO_ADC1_IN12);
px4_arch_configgpio(GPIO_ADC1_IN13); // jumperable to MPU6000 DRDY on some boards stm32_configgpio(GPIO_ADC1_IN13); // jumperable to MPU6000 DRDY on some boards
#endif #endif
/* Get the SPI port for the microSD slot */ /* Get the SPI port for the microSD slot */
spi3 = px4_spibus_initialize(3); spi3 = stm32_spibus_initialize(3);
if (!spi3) { if (!spi3) {
message("[boot] FAILED to initialize SPI port 3\n"); message("[boot] FAILED to initialize SPI port 3\n");
up_ledon(LED_AMBER); board_autoled_on(LED_AMBER);
return -ENODEV; return -ENODEV;
} }
@@ -242,7 +274,7 @@ __EXPORT int nsh_archinitialize(void)
if (result != OK) { if (result != OK) {
message("[boot] FAILED to bind SPI port 3 to the MMCSD driver\n"); message("[boot] FAILED to bind SPI port 3 to the MMCSD driver\n");
up_ledon(LED_AMBER); board_autoled_on(LED_AMBER);
return -ENODEV; return -ENODEV;
} }
+12 -12
View File
@@ -64,20 +64,20 @@ __EXPORT void led_init(void)
{ {
/* Configure LED1-2 GPIOs for output */ /* Configure LED1-2 GPIOs for output */
px4_arch_configgpio(GPIO_LED1); stm32_configgpio(GPIO_LED1);
px4_arch_configgpio(GPIO_LED2); stm32_configgpio(GPIO_LED2);
} }
__EXPORT void led_on(int led) __EXPORT void led_on(int led)
{ {
if (led == 0) { if (led == 0) {
/* Pull down to switch on */ /* Pull down to switch on */
px4_arch_gpiowrite(GPIO_LED1, false); stm32_gpiowrite(GPIO_LED1, false);
} }
if (led == 1) { if (led == 1) {
/* Pull down to switch on */ /* Pull down to switch on */
px4_arch_gpiowrite(GPIO_LED2, false); stm32_gpiowrite(GPIO_LED2, false);
} }
} }
@@ -85,32 +85,32 @@ __EXPORT void led_off(int led)
{ {
if (led == 0) { if (led == 0) {
/* Pull up to switch off */ /* Pull up to switch off */
px4_arch_gpiowrite(GPIO_LED1, true); stm32_gpiowrite(GPIO_LED1, true);
} }
if (led == 1) { if (led == 1) {
/* Pull up to switch off */ /* Pull up to switch off */
px4_arch_gpiowrite(GPIO_LED2, true); stm32_gpiowrite(GPIO_LED2, true);
} }
} }
__EXPORT void led_toggle(int led) __EXPORT void led_toggle(int led)
{ {
if (led == 0) { if (led == 0) {
if (px4_arch_gpioread(GPIO_LED1)) { if (stm32_gpioread(GPIO_LED1)) {
px4_arch_gpiowrite(GPIO_LED1, false); stm32_gpiowrite(GPIO_LED1, false);
} else { } else {
px4_arch_gpiowrite(GPIO_LED1, true); stm32_gpiowrite(GPIO_LED1, true);
} }
} }
if (led == 1) { if (led == 1) {
if (px4_arch_gpioread(GPIO_LED2)) { if (stm32_gpioread(GPIO_LED2)) {
px4_arch_gpiowrite(GPIO_LED2, false); stm32_gpiowrite(GPIO_LED2, false);
} else { } else {
px4_arch_gpiowrite(GPIO_LED2, true); stm32_gpiowrite(GPIO_LED2, true);
} }
} }
} }
+22 -19
View File
@@ -47,7 +47,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <debug.h> #include <debug.h>
#include <nuttx/spi.h> #include <nuttx/spi/spi.h>
#include <arch/board/board.h> #include <arch/board/board.h>
#include "up_arch.h" #include "up_arch.h"
@@ -69,19 +69,19 @@
__EXPORT void stm32_spiinitialize(void) __EXPORT void stm32_spiinitialize(void)
{ {
px4_arch_configgpio(GPIO_SPI_CS_GYRO); stm32_configgpio(GPIO_SPI_CS_GYRO);
px4_arch_configgpio(GPIO_SPI_CS_ACCEL); stm32_configgpio(GPIO_SPI_CS_ACCEL);
px4_arch_configgpio(GPIO_SPI_CS_MPU); stm32_configgpio(GPIO_SPI_CS_MPU);
px4_arch_configgpio(GPIO_SPI_CS_SDCARD); stm32_configgpio(GPIO_SPI_CS_SDCARD);
/* De-activate all peripherals, /* De-activate all peripherals,
* required for some peripheral * required for some peripheral
* state machines * state machines
*/ */
px4_arch_gpiowrite(GPIO_SPI_CS_GYRO, 1); stm32_gpiowrite(GPIO_SPI_CS_GYRO, 1);
px4_arch_gpiowrite(GPIO_SPI_CS_ACCEL, 1); stm32_gpiowrite(GPIO_SPI_CS_ACCEL, 1);
px4_arch_gpiowrite(GPIO_SPI_CS_MPU, 1); stm32_gpiowrite(GPIO_SPI_CS_MPU, 1);
px4_arch_gpiowrite(GPIO_SPI_CS_SDCARD, 1); stm32_gpiowrite(GPIO_SPI_CS_SDCARD, 1);
} }
__EXPORT void stm32_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected) __EXPORT void stm32_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
@@ -91,23 +91,23 @@ __EXPORT void stm32_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid,
switch (devid) { switch (devid) {
case PX4_SPIDEV_GYRO: case PX4_SPIDEV_GYRO:
/* Making sure the other peripherals are not selected */ /* Making sure the other peripherals are not selected */
px4_arch_gpiowrite(GPIO_SPI_CS_GYRO, !selected); stm32_gpiowrite(GPIO_SPI_CS_GYRO, !selected);
px4_arch_gpiowrite(GPIO_SPI_CS_MPU, 1); stm32_gpiowrite(GPIO_SPI_CS_MPU, 1);
px4_arch_gpiowrite(GPIO_SPI_CS_ACCEL, 1); stm32_gpiowrite(GPIO_SPI_CS_ACCEL, 1);
break; break;
case PX4_SPIDEV_ACCEL: case PX4_SPIDEV_ACCEL:
/* Making sure the other peripherals are not selected */ /* Making sure the other peripherals are not selected */
px4_arch_gpiowrite(GPIO_SPI_CS_ACCEL, !selected); stm32_gpiowrite(GPIO_SPI_CS_ACCEL, !selected);
px4_arch_gpiowrite(GPIO_SPI_CS_MPU, 1); stm32_gpiowrite(GPIO_SPI_CS_MPU, 1);
px4_arch_gpiowrite(GPIO_SPI_CS_GYRO, 1); stm32_gpiowrite(GPIO_SPI_CS_GYRO, 1);
break; break;
case PX4_SPIDEV_MPU: case PX4_SPIDEV_MPU:
/* Making sure the other peripherals are not selected */ /* Making sure the other peripherals are not selected */
px4_arch_gpiowrite(GPIO_SPI_CS_ACCEL, 1); stm32_gpiowrite(GPIO_SPI_CS_ACCEL, 1);
px4_arch_gpiowrite(GPIO_SPI_CS_GYRO, 1); stm32_gpiowrite(GPIO_SPI_CS_GYRO, 1);
px4_arch_gpiowrite(GPIO_SPI_CS_MPU, !selected); stm32_gpiowrite(GPIO_SPI_CS_MPU, !selected);
break; break;
default: default:
@@ -121,6 +121,8 @@ __EXPORT uint8_t stm32_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devi
return SPI_STATUS_PRESENT; return SPI_STATUS_PRESENT;
} }
#ifdef CONFIG_STM32_SPI2
__EXPORT void stm32_spi2select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected) __EXPORT void stm32_spi2select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{ {
/* SPI select is active low, so write !selected to select the device */ /* SPI select is active low, so write !selected to select the device */
@@ -138,12 +140,13 @@ __EXPORT uint8_t stm32_spi2status(FAR struct spi_dev_s *dev, enum spi_dev_e devi
{ {
return SPI_STATUS_PRESENT; return SPI_STATUS_PRESENT;
} }
#endif
__EXPORT void stm32_spi3select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected) __EXPORT void stm32_spi3select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{ {
/* there can only be one device on this bus, so always select it */ /* there can only be one device on this bus, so always select it */
px4_arch_gpiowrite(GPIO_SPI_CS_SDCARD, !selected); stm32_gpiowrite(GPIO_SPI_CS_SDCARD, !selected);
} }
__EXPORT uint8_t stm32_spi3status(FAR struct spi_dev_s *dev, enum spi_dev_e devid) __EXPORT uint8_t stm32_spi3status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
+4 -4
View File
@@ -82,10 +82,10 @@ __EXPORT void stm32_usbinitialize(void)
/* Configure the OTG FS VBUS sensing GPIO, Power On, and Overcurrent GPIOs */ /* Configure the OTG FS VBUS sensing GPIO, Power On, and Overcurrent GPIOs */
#ifdef CONFIG_STM32_OTGFS #ifdef CONFIG_STM32_OTGFS
px4_arch_configgpio(GPIO_OTGFS_VBUS); stm32_configgpio(GPIO_OTGFS_VBUS);
/* XXX We only support device mode /* XXX We only support device mode
px4_arch_configgpio(GPIO_OTGFS_PWRON); stm32_configgpio(GPIO_OTGFS_PWRON);
px4_arch_configgpio(GPIO_OTGFS_OVER); stm32_configgpio(GPIO_OTGFS_OVER);
*/ */
#endif #endif
} }
@@ -103,6 +103,6 @@ __EXPORT void stm32_usbinitialize(void)
__EXPORT void stm32_usbsuspend(FAR struct usbdev_s *dev, bool resume) __EXPORT void stm32_usbsuspend(FAR struct usbdev_s *dev, bool resume)
{ {
//ulldbg("resume: %d\n", resume); uinfo("resume: %d\n", resume);
} }