From abe16d7242d686ec11627b8a32eee6699cc1ccad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Wed, 25 Mar 2020 11:48:55 +0100 Subject: [PATCH] cuav/nora: some cleanup & rebase fixups --- ROMFS/px4fmu_common/init.d/rc.interface | 24 ++ boards/cuav/nora/default.cmake | 3 - boards/cuav/nora/init/rc.board_defaults | 38 -- boards/cuav/nora/init/rc.board_mavlink | 4 - boards/cuav/nora/init/rc.board_sensors | 24 +- boards/cuav/nora/nuttx-config/nsh/defconfig | 5 + .../nora/nuttx-config/stackcheck/defconfig | 255 -------------- boards/cuav/nora/src/CMakeLists.txt | 2 + boards/cuav/nora/src/board_config.h | 142 -------- boards/cuav/nora/src/i2c.cpp | 42 +++ boards/cuav/nora/src/init.c | 14 +- boards/cuav/nora/src/spi.cpp | 331 ++---------------- boards/cuav/nora/src/timer_config.cpp | 1 - boards/cuav/nora/stackcheck.cmake | 126 ------- src/drivers/px4fmu/fmu.cpp | 9 +- 15 files changed, 124 insertions(+), 896 deletions(-) delete mode 100644 boards/cuav/nora/nuttx-config/stackcheck/defconfig create mode 100644 boards/cuav/nora/src/i2c.cpp mode change 100755 => 100644 boards/cuav/nora/src/spi.cpp delete mode 100755 boards/cuav/nora/stackcheck.cmake diff --git a/ROMFS/px4fmu_common/init.d/rc.interface b/ROMFS/px4fmu_common/init.d/rc.interface index 2a4764ecb643..b28112c3c153 100644 --- a/ROMFS/px4fmu_common/init.d/rc.interface +++ b/ROMFS/px4fmu_common/init.d/rc.interface @@ -277,6 +277,12 @@ then pwm disarmed -c 6 -p p:PWM_AUX_DIS6 -d ${OUTPUT_AUX_DEV} pwm disarmed -c 7 -p p:PWM_AUX_DIS7 -d ${OUTPUT_AUX_DEV} pwm disarmed -c 8 -p p:PWM_AUX_DIS8 -d ${OUTPUT_AUX_DEV} + pwm disarmed -m 0x100 -p p:PWM_MAIN_DIS9 -d ${OUTPUT_AUX_DEV} + pwm disarmed -m 0x200 -p p:PWM_MAIN_DIS10 -d ${OUTPUT_AUX_DEV} + pwm disarmed -m 0x400 -p p:PWM_MAIN_DIS11 -d ${OUTPUT_AUX_DEV} + pwm disarmed -m 0x800 -p p:PWM_MAIN_DIS12 -d ${OUTPUT_AUX_DEV} + pwm disarmed -m 0x1000 -p p:PWM_MAIN_DIS13 -d ${OUTPUT_AUX_DEV} + pwm disarmed -m 0x2000 -p p:PWM_MAIN_DIS14 -d ${OUTPUT_AUX_DEV} # # Per channel min settings. @@ -289,6 +295,12 @@ then pwm min -c 6 -p p:PWM_AUX_MIN6 -d ${OUTPUT_AUX_DEV} pwm min -c 7 -p p:PWM_AUX_MIN7 -d ${OUTPUT_AUX_DEV} pwm min -c 8 -p p:PWM_AUX_MIN8 -d ${OUTPUT_AUX_DEV} + pwm min -m 0x100 -p p:PWM_MAIN_MIN9 -d ${OUTPUT_AUX_DEV} + pwm min -m 0x200 -p p:PWM_MAIN_MIN10 -d ${OUTPUT_AUX_DEV} + pwm min -m 0x400 -p p:PWM_MAIN_MIN11 -d ${OUTPUT_AUX_DEV} + pwm min -m 0x800 -p p:PWM_MAIN_MIN12 -d ${OUTPUT_AUX_DEV} + pwm min -m 0x1000 -p p:PWM_MAIN_MIN13 -d ${OUTPUT_AUX_DEV} + pwm min -m 0x2000 -p p:PWM_MAIN_MIN14 -d ${OUTPUT_AUX_DEV} # # Per channel max settings. @@ -301,6 +313,12 @@ then pwm max -c 6 -p p:PWM_AUX_MAX6 -d ${OUTPUT_AUX_DEV} pwm max -c 7 -p p:PWM_AUX_MAX7 -d ${OUTPUT_AUX_DEV} pwm max -c 8 -p p:PWM_AUX_MAX8 -d ${OUTPUT_AUX_DEV} + pwm max -m 0x100 -p p:PWM_MAIN_MAX9 -d ${OUTPUT_AUX_DEV} + pwm max -m 0x200 -p p:PWM_MAIN_MAX10 -d ${OUTPUT_AUX_DEV} + pwm max -m 0x400 -p p:PWM_MAIN_MAX11 -d ${OUTPUT_AUX_DEV} + pwm max -m 0x800 -p p:PWM_MAIN_MAX12 -d ${OUTPUT_AUX_DEV} + pwm max -m 0x1000 -p p:PWM_MAIN_MAX13 -d ${OUTPUT_AUX_DEV} + pwm max -m 0x2000 -p p:PWM_MAIN_MAX14 -d ${OUTPUT_AUX_DEV} if [ $FAILSAFE_AUX != none ] then @@ -318,6 +336,12 @@ then pwm failsafe -c 6 -p p:PWM_AUX_FAIL6 -d ${OUTPUT_AUX_DEV} pwm failsafe -c 7 -p p:PWM_AUX_FAIL7 -d ${OUTPUT_AUX_DEV} pwm failsafe -c 8 -p p:PWM_AUX_FAIL8 -d ${OUTPUT_AUX_DEV} + pwm failsafe -m 0x100 -p p:PWM_MAIN_FAIL9 -d ${OUTPUT_AUX_DEV} + pwm failsafe -m 0x200 -p p:PWM_MAIN_FAIL10 -d ${OUTPUT_AUX_DEV} + pwm failsafe -m 0x400 -p p:PWM_MAIN_FAIL11 -d ${OUTPUT_AUX_DEV} + pwm failsafe -m 0x800 -p p:PWM_MAIN_FAIL12 -d ${OUTPUT_AUX_DEV} + pwm failsafe -m 0x1000 -p p:PWM_MAIN_FAIL13 -d ${OUTPUT_AUX_DEV} + pwm failsafe -m 0x2000 -p p:PWM_MAIN_FAIL14 -d ${OUTPUT_AUX_DEV} fi fi fi diff --git a/boards/cuav/nora/default.cmake b/boards/cuav/nora/default.cmake index d7de1ff2a754..75fc32d40fa3 100755 --- a/boards/cuav/nora/default.cmake +++ b/boards/cuav/nora/default.cmake @@ -8,7 +8,6 @@ px4_add_board( ARCHITECTURE cortex-m7 ROMFSROOT px4fmu_common BUILD_BOOTLOADER - IO px4_io-v2_default TESTING # UAVCAN_INTERFACES 2 - No H7 or FD can support in UAVCAN SERIAL_PORTS @@ -50,7 +49,6 @@ px4_add_board( # all arch dependant code there pwm_out_sim px4fmu - px4io rc_input rpm @@ -117,7 +115,6 @@ px4_add_board( ver work_queue EXAMPLES - bottle_drop # OBC challenge fixedwing_control # Tutorial code from https://px4.io/dev/example_fixedwing_control hello hwtest # Hardware test diff --git a/boards/cuav/nora/init/rc.board_defaults b/boards/cuav/nora/init/rc.board_defaults index 5bd14e5f2129..67411d7b7b17 100755 --- a/boards/cuav/nora/init/rc.board_defaults +++ b/boards/cuav/nora/init/rc.board_defaults @@ -22,12 +22,6 @@ then fi unset BL_FILE -# -# No px4IO -# -unset IOFW -param set SYS_USE_IO 0 - if [ $AUTOCNF = yes ] then @@ -39,35 +33,3 @@ set LOGGER_BUF 64 safety_button start -fmu mode_pwm -pwm rate -a -r 400 - -pwm disarmed -m 0x100 -p p:PWM_MAIN_DIS9 -pwm disarmed -m 0x200 -p p:PWM_MAIN_DIS10 -pwm disarmed -m 0x400 -p p:PWM_MAIN_DIS11 -pwm disarmed -m 0x800 -p p:PWM_MAIN_DIS12 -pwm disarmed -m 0x1000 -p p:PWM_MAIN_DIS13 -pwm disarmed -m 0x2000 -p p:PWM_MAIN_DIS14 - -pwm min -m 0x100 -p p:PWM_MAIN_MIN9 -pwm min -m 0x200 -p p:PWM_MAIN_MIN10 -pwm min -m 0x400 -p p:PWM_MAIN_MIN11 -pwm min -m 0x800 -p p:PWM_MAIN_MIN12 -pwm min -m 0x1000 -p p:PWM_MAIN_MIN13 -pwm min -m 0x2000 -p p:PWM_MAIN_MIN14 - -pwm max -m 0x100 -p p:PWM_MAIN_MAX9 -pwm max -m 0x200 -p p:PWM_MAIN_MAX10 -pwm max -m 0x400 -p p:PWM_MAIN_MAX11 -pwm max -m 0x800 -p p:PWM_MAIN_MAX12 -pwm max -m 0x1000 -p p:PWM_MAIN_MAX13 -pwm max -m 0x2000 -p p:PWM_MAIN_MAX14 - -pwm failsafe -m 0x100 -p p:PWM_MAIN_FAIL9 -pwm failsafe -m 0x200 -p p:PWM_MAIN_FAIL10 -pwm failsafe -m 0x400 -p p:PWM_MAIN_FAIL11 -pwm failsafe -m 0x800 -p p:PWM_MAIN_FAIL12 -pwm failsafe -m 0x1000 -p p:PWM_MAIN_FAIL13 -pwm failsafe -m 0x2000 -p p:PWM_MAIN_FAIL14 - -set PWM_RATE none diff --git a/boards/cuav/nora/init/rc.board_mavlink b/boards/cuav/nora/init/rc.board_mavlink index 1f0a3461e0f5..ed942b34419d 100755 --- a/boards/cuav/nora/init/rc.board_mavlink +++ b/boards/cuav/nora/init/rc.board_mavlink @@ -6,7 +6,3 @@ # Start MAVLink on the USB port mavlink start -d /dev/ttyACM0 -# Start MAVLink on the uart port -mavlink start -d /dev/ttyS3 - -#gps start -d /dev/ttyS2 diff --git a/boards/cuav/nora/init/rc.board_sensors b/boards/cuav/nora/init/rc.board_sensors index fe08d745c258..5c8c06e9aa19 100755 --- a/boards/cuav/nora/init/rc.board_sensors +++ b/boards/cuav/nora/init/rc.board_sensors @@ -5,29 +5,25 @@ adc start # Internal SPI bus ICM-20689 -mpu6000 -R 8 -z -T 20689 start -#$icm20948 -R start +mpu6000 -R 8 -s -T 20689 start +#icm20948 -R start # Internal SPI bus BMI088 accel -bmi088 -A -R 10 start - +bmi088 -A -s -R 10 start # Internal SPI bus BMI088 gyro -bmi088 -G -R 10 start +bmi088 -G -s -R 10 start -#rm3100 -R 1 start -rm3100 start -# Possible external compasses -ist8310 -b 4 start +rm3100 -s start -hmc5883 -C -T -X start +# Possible external compasses +ist8310 -X start +hmc5883 -T -X start qmc5883 -X start lis3mdl -X start # Possible internal compass -ist8310 -b 5 start +ist8310 -I start # Baro on internal SPI -ms5611 -S start - -# Baro on external SPI ms5611 -s start + diff --git a/boards/cuav/nora/nuttx-config/nsh/defconfig b/boards/cuav/nora/nuttx-config/nsh/defconfig index 6a44eeb52aa6..b3643ee2f65b 100644 --- a/boards/cuav/nora/nuttx-config/nsh/defconfig +++ b/boards/cuav/nora/nuttx-config/nsh/defconfig @@ -192,6 +192,7 @@ CONFIG_STM32H7_SERIAL_DISABLE_REORDERING=y CONFIG_STM32H7_SPI1=y CONFIG_STM32H7_SPI2=y CONFIG_STM32H7_SPI4=y +CONFIG_STM32H7_SPI5=y CONFIG_STM32H7_SPI6=y CONFIG_STM32H7_TIM12=y CONFIG_STM32H7_TIM15=y @@ -217,6 +218,7 @@ CONFIG_TIME_EXTENDED=y CONFIG_TTY_SIGINT=y CONFIG_TTY_SIGSTP=y CONFIG_UART4_BAUD=57600 +CONFIG_UART4_DMA=y CONFIG_UART4_RXBUFSIZE=600 CONFIG_UART4_TXBUFSIZE=1500 CONFIG_UART7_BAUD=57600 @@ -224,12 +226,15 @@ CONFIG_UART7_RXBUFSIZE=600 CONFIG_UART7_SERIAL_CONSOLE=y CONFIG_UART7_TXBUFSIZE=1500 CONFIG_UART8_BAUD=57600 +CONFIG_UART8_DMA=y CONFIG_UART8_RXBUFSIZE=600 CONFIG_UART8_TXBUFSIZE=1500 CONFIG_USART1_BAUD=57600 +CONFIG_USART1_DMA=y CONFIG_USART1_RXBUFSIZE=600 CONFIG_USART1_TXBUFSIZE=1500 CONFIG_USART2_BAUD=57600 +CONFIG_USART2_DMA=y CONFIG_USART2_IFLOWCONTROL=y CONFIG_USART2_OFLOWCONTROL=y CONFIG_USART2_RXBUFSIZE=600 diff --git a/boards/cuav/nora/nuttx-config/stackcheck/defconfig b/boards/cuav/nora/nuttx-config/stackcheck/defconfig deleted file mode 100644 index 3f024b816244..000000000000 --- a/boards/cuav/nora/nuttx-config/stackcheck/defconfig +++ /dev/null @@ -1,255 +0,0 @@ -# -# This file is autogenerated: PLEASE DO NOT EDIT IT. -# -# You can use "make menuconfig" to make any modifications to the installed .config file. -# You can then do "make savedefconfig" to generate a new defconfig file that includes your -# modifications. -# -# CONFIG_DISABLE_OS_API is not set -# CONFIG_DISABLE_PSEUDOFS_OPERATIONS is not set -# CONFIG_MMCSD_HAVE_CARDDETECT is not set -# CONFIG_MMCSD_HAVE_WRITEPROTECT is not set -# CONFIG_MMCSD_MMCSUPPORT is not set -# CONFIG_MMCSD_SPI is not set -# CONFIG_NSH_DISABLEBG is not set -# CONFIG_NSH_DISABLESCRIPT is not set -# CONFIG_NSH_DISABLE_DF is not set -# CONFIG_NSH_DISABLE_EXEC is not set -# CONFIG_NSH_DISABLE_EXIT is not set -# CONFIG_NSH_DISABLE_GET is not set -# CONFIG_NSH_DISABLE_ITEF is not set -# CONFIG_NSH_DISABLE_LOOPS is not set -# CONFIG_NSH_DISABLE_SEMICOLON is not set -# CONFIG_NSH_DISABLE_TIME is not set -CONFIG_ARCH="arm" -CONFIG_ARCH_BOARD_CUSTOM=y -CONFIG_ARCH_BOARD_CUSTOM_DIR="../nuttx-config" -CONFIG_ARCH_BOARD_CUSTOM_DIR_RELPATH=y -CONFIG_ARCH_BOARD_CUSTOM_NAME="px4" -CONFIG_ARCH_CHIP="stm32h7" -CONFIG_ARCH_CHIP_STM32H743ZI=y -CONFIG_ARCH_CHIP_STM32H7=y -CONFIG_ARCH_INTERRUPTSTACK=512 -CONFIG_ARCH_STACKDUMP=y -CONFIG_ARMV7M_BASEPRI_WAR=y -CONFIG_ARMV7M_DCACHE=y -CONFIG_ARMV7M_DTCM=y -CONFIG_ARMV7M_ICACHE=y -CONFIG_ARMV7M_MEMCPY=y -CONFIG_ARMV7M_STACKCHECK=y -CONFIG_ARMV7M_USEBASEPRI=y -CONFIG_BOARDCTL_RESET=y -CONFIG_BOARD_CRASHDUMP=y -CONFIG_BOARD_LOOPSPERMSEC=95150 -CONFIG_BOARD_RESET_ON_ASSERT=2 -CONFIG_BUILTIN=y -CONFIG_C99_BOOL8=y -CONFIG_CDCACM=y -CONFIG_CDCACM_PRODUCTID=0x004c -CONFIG_CDCACM_PRODUCTSTR="PX4 Nora" -CONFIG_CDCACM_RXBUFSIZE=600 -CONFIG_CDCACM_TXBUFSIZE=12000 -CONFIG_CDCACM_VENDORID=0x3163 -CONFIG_CDCACM_VENDORSTR="Cuav" -CONFIG_CLOCK_MONOTONIC=y -CONFIG_DEBUG_FULLOPT=y -CONFIG_DEBUG_HARDFAULT_ALERT=y -CONFIG_DEBUG_SYMBOLS=y -CONFIG_DEFAULT_SMALL=y -CONFIG_DEV_FIFO_SIZE=0 -CONFIG_DEV_PIPE_MAXSIZE=1024 -CONFIG_DEV_PIPE_SIZE=70 -CONFIG_EXPERIMENTAL=y -CONFIG_FAT_DMAMEMORY=y -CONFIG_FAT_LCNAMES=y -CONFIG_FAT_LFN=y -CONFIG_FAT_LFN_ALIAS_HASH=y -CONFIG_FDCLONE_STDIO=y -CONFIG_FS_BINFS=y -CONFIG_FS_CROMFS=y -CONFIG_FS_FAT=y -CONFIG_FS_FATTIME=y -CONFIG_FS_PROCFS=y -CONFIG_FS_PROCFS_EXCLUDE_BLOCKS=y -CONFIG_FS_PROCFS_EXCLUDE_MOUNT=y -CONFIG_FS_PROCFS_EXCLUDE_MOUNTS=y -CONFIG_FS_PROCFS_EXCLUDE_PARTITIONS=y -CONFIG_FS_PROCFS_EXCLUDE_USAGE=y -CONFIG_FS_PROCFS_REGISTER=y -CONFIG_FS_ROMFS=y -CONFIG_GRAN=y -CONFIG_GRAN_INTR=y -CONFIG_HAVE_CXX=y -CONFIG_HAVE_CXXINITIALIZE=y -CONFIG_I2C=y -CONFIG_I2C_RESET=y -CONFIG_IDLETHREAD_STACKSIZE=750 -CONFIG_LIBC_FLOATINGPOINT=y -CONFIG_LIBC_LONG_LONG=y -CONFIG_LIBC_STRERROR=y -CONFIG_MAX_TASKS=64 -CONFIG_MAX_WDOGPARMS=2 -CONFIG_MEMSET_64BIT=y -CONFIG_MEMSET_OPTSPEED=y -CONFIG_MMCSD=y -CONFIG_MMCSD_MULTIBLOCK_DISABLE=y -CONFIG_MMCSD_SDIO=y -CONFIG_MMCSD_SDIOWAIT_WRCOMPLETE=y -CONFIG_MM_REGIONS=3 -CONFIG_MTD=y -CONFIG_MTD_BYTE_WRITE=y -CONFIG_MTD_PARTITION=y -CONFIG_MTD_PROGMEM=y -CONFIG_MTD_RAMTRON=y -CONFIG_NFILE_DESCRIPTORS=20 -CONFIG_NFILE_STREAMS=8 -CONFIG_NSH_ARCHINIT=y -CONFIG_NSH_ARCHROMFS=y -CONFIG_NSH_ARGCAT=y -CONFIG_NSH_BUILTIN_APPS=y -CONFIG_NSH_CMDPARMS=y -CONFIG_NSH_CROMFSETC=y -CONFIG_NSH_DISABLE_IFCONFIG=y -CONFIG_NSH_DISABLE_IFUPDOWN=y -CONFIG_NSH_DISABLE_MB=y -CONFIG_NSH_DISABLE_MH=y -CONFIG_NSH_DISABLE_TELNETD=y -CONFIG_NSH_LINELEN=128 -CONFIG_NSH_MAXARGUMENTS=12 -CONFIG_NSH_NESTDEPTH=8 -CONFIG_NSH_QUOTE=y -CONFIG_NSH_ROMFSETC=y -CONFIG_NSH_ROMFSSECTSIZE=128 -CONFIG_NSH_STRERROR=y -CONFIG_NSH_VARS=y -CONFIG_NXFONTS_DISABLE_16BPP=y -CONFIG_NXFONTS_DISABLE_1BPP=y -CONFIG_NXFONTS_DISABLE_24BPP=y -CONFIG_NXFONTS_DISABLE_2BPP=y -CONFIG_NXFONTS_DISABLE_32BPP=y -CONFIG_NXFONTS_DISABLE_4BPP=y -CONFIG_NXFONTS_DISABLE_8BPP=y -CONFIG_PIPES=y -CONFIG_PREALLOC_MQ_MSGS=4 -CONFIG_PREALLOC_TIMERS=50 -CONFIG_PREALLOC_WDOGS=50 -CONFIG_PRIORITY_INHERITANCE=y -CONFIG_PTHREAD_MUTEX_ROBUST=y -CONFIG_PTHREAD_STACK_MIN=512 -CONFIG_RAMTRON_SETSPEED=y -CONFIG_RAMTRON_WRITEWAIT=y -CONFIG_RAM_SIZE=245760 -CONFIG_RAM_START=0x20010000 -CONFIG_RAW_BINARY=y -CONFIG_RTC_DATETIME=y -CONFIG_SCHED_ATEXIT=y -CONFIG_SCHED_HPWORK=y -CONFIG_SCHED_HPWORKPRIORITY=249 -CONFIG_SCHED_HPWORKSTACKSIZE=1280 -CONFIG_SCHED_INSTRUMENTATION=y -CONFIG_SCHED_LPWORK=y -CONFIG_SCHED_LPWORKPRIORITY=50 -CONFIG_SCHED_LPWORKSTACKSIZE=1536 -CONFIG_SCHED_WAITPID=y -CONFIG_SDCLONE_DISABLE=y -CONFIG_SDMMC1_SDIO_MODE=y -CONFIG_SEM_NNESTPRIO=8 -CONFIG_SEM_PREALLOCHOLDERS=0 -CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS=y -CONFIG_SERIAL_TERMIOS=y -CONFIG_SIG_DEFAULT=y -CONFIG_SIG_SIGALRM_ACTION=y -CONFIG_SIG_SIGUSR1_ACTION=y -CONFIG_SIG_SIGUSR2_ACTION=y -CONFIG_SIG_SIGWORK=4 -CONFIG_STACK_COLORATION=y -CONFIG_START_DAY=30 -CONFIG_START_MONTH=11 -CONFIG_STDIO_BUFFER_SIZE=32 -CONFIG_STM32H7_ADC1=y -CONFIG_STM32H7_BBSRAM=y -CONFIG_STM32H7_BBSRAM_FILES=5 -CONFIG_STM32H7_BKPSRAM=y -CONFIG_STM32H7_DMA1=y -CONFIG_STM32H7_DMA2=y -CONFIG_STM32H7_DMACAPABLE=y -CONFIG_STM32H7_DTCMEXCLUDE=y -CONFIG_STM32H7_DTCM_PROCFS=y -CONFIG_STM32H7_FLOWCONTROL_BROKEN=y -CONFIG_STM32H7_I2C1=y -CONFIG_STM32H7_I2C2=y -CONFIG_STM32H7_I2C3=y -CONFIG_STM32H7_I2C4=y -CONFIG_STM32H7_I2C_DYNTIMEO=y -CONFIG_STM32H7_I2C_DYNTIMEO_STARTSTOP=10 -CONFIG_STM32H7_OTGFS=y -CONFIG_STM32H7_PROGMEM=y -CONFIG_STM32H7_RTC=y -CONFIG_STM32H7_RTC_MAGIC_REG=1 -CONFIG_STM32H7_SAVE_CRASHDUMP=y -CONFIG_STM32H7_SDMMC1=y -CONFIG_STM32H7_SERIALBRK_BSDCOMPAT=y -CONFIG_STM32H7_SERIAL_DISABLE_REORDERING=y -CONFIG_STM32H7_SPI1=y -CONFIG_STM32H7_SPI2=y -CONFIG_STM32H7_SPI4=y -CONFIG_STM32H7_SPI6=y -CONFIG_STM32H7_TIM1=y -CONFIG_STM32H7_TIM3=y -CONFIG_STM32H7_TIM4=y -CONFIG_STM32H7_UART4=y -CONFIG_STM32H7_UART7=y -CONFIG_STM32H7_UART8=y -CONFIG_STM32H7_USART1=y -CONFIG_STM32H7_USART2=y -CONFIG_STM32H7_USART3=y -CONFIG_STM32H7_USART6=y -CONFIG_STM32H7_USART_BREAKS=y -CONFIG_STM32H7_USART_INVERT=y -CONFIG_STM32H7_USART_SINGLEWIRE=y -CONFIG_STM32H7_USART_SWAP=y -CONFIG_SYSTEM_CDCACM=y -CONFIG_SYSTEM_NSH=y -CONFIG_TASK_NAME_SIZE=24 -CONFIG_TIME_EXTENDED=y -CONFIG_TTY_SIGINT=y -CONFIG_TTY_SIGSTP=y -CONFIG_UART4_BAUD=57600 -CONFIG_UART4_DMA=y -CONFIG_UART4_RXBUFSIZE=600 -CONFIG_UART4_TXBUFSIZE=1500 -CONFIG_UART7_BAUD=57600 -CONFIG_UART7_RXBUFSIZE=600 -CONFIG_UART7_SERIAL_CONSOLE=y -CONFIG_UART7_TXBUFSIZE=1500 -CONFIG_UART8_BAUD=57600 -CONFIG_UART8_DMA=y -CONFIG_UART8_RXBUFSIZE=600 -CONFIG_UART8_TXBUFSIZE=1500 -CONFIG_USART1_BAUD=57600 -CONFIG_USART1_DMA=y -CONFIG_USART1_RXBUFSIZE=600 -CONFIG_USART1_TXBUFSIZE=1500 -CONFIG_USART2_BAUD=57600 -CONFIG_USART2_DMA=y -CONFIG_USART2_IFLOWCONTROL=y -CONFIG_USART2_OFLOWCONTROL=y -CONFIG_USART2_RXBUFSIZE=600 -CONFIG_USART2_TXBUFSIZE=1500 -CONFIG_USART3_BAUD=57600 -CONFIG_USART3_DMA=y -CONFIG_USART3_IFLOWCONTROL=y -CONFIG_USART3_OFLOWCONTROL=y -CONFIG_USART3_RXBUFSIZE=600 -CONFIG_USART3_TXBUFSIZE=3000 -CONFIG_USART6_BAUD=57600 -CONFIG_USART6_DMA=y -CONFIG_USART6_RXBUFSIZE=600 -CONFIG_USART6_TXBUFSIZE=1500 -CONFIG_USBDEV=y -CONFIG_USBDEV_BUSPOWERED=y -CONFIG_USBDEV_MAXPOWER=500 -CONFIG_USEC_PER_TICK=1000 -CONFIG_USERMAIN_STACKSIZE=2624 -CONFIG_USER_ENTRYPOINT="nsh_main" -CONFIG_WATCHDOG=y diff --git a/boards/cuav/nora/src/CMakeLists.txt b/boards/cuav/nora/src/CMakeLists.txt index cfac87b66666..2be96b170df9 100755 --- a/boards/cuav/nora/src/CMakeLists.txt +++ b/boards/cuav/nora/src/CMakeLists.txt @@ -46,6 +46,7 @@ if("${PX4_BOARD_LABEL}" STREQUAL "bootloader") else() add_library(drivers_board can.c + i2c.cpp init.c led.c manifest.c @@ -58,6 +59,7 @@ else() target_link_libraries(drivers_board PRIVATE + arch_spi arch_board_hw_info drivers__led # drv_led_start nuttx_arch # sdio diff --git a/boards/cuav/nora/src/board_config.h b/boards/cuav/nora/src/board_config.h index 2c4ac18f85a4..a0603506cee8 100755 --- a/boards/cuav/nora/src/board_config.h +++ b/boards/cuav/nora/src/board_config.h @@ -53,20 +53,6 @@ * Definitions ****************************************************************************************************/ -/* PX4IO connection configuration */ - -#define BOARD_USES_PX4IO_VERSION 2 -#define PX4IO_SERIAL_DEVICE "/dev/ttyS5" -#define PX4IO_SERIAL_TX_GPIO GPIO_UART8_TX -#define PX4IO_SERIAL_RX_GPIO GPIO_UART8_RX -#define PX4IO_SERIAL_BASE STM32_UART8_BASE -#define PX4IO_SERIAL_VECTOR STM32_IRQ_UART8 -#define PX4IO_SERIAL_TX_DMAMAP DMAMAP_UART8_TX -#define PX4IO_SERIAL_RX_DMAMAP DMAMAP_UART8_RX -#define PX4IO_SERIAL_RCC_REG STM32_RCC_APB1LENR -#define PX4IO_SERIAL_RCC_EN RCC_APB1LENR_UART8EN -#define PX4IO_SERIAL_CLOCK STM32_PCLK1_FREQUENCY -#define PX4IO_SERIAL_BITRATE 1500000 /* 1.5Mbps -> max rate for IO */ #define STM32_RCC_APB1ENR STM32_RCC_APB1LENR #define RCC_APB1ENR_TIM3EN RCC_APB1LENR_TIM3EN @@ -90,126 +76,6 @@ #define BOARD_OVERLOAD_LED LED_RED #define BOARD_ARMED_STATE_LED LED_BLUE -/* SENSORS are on SPI1, 5, 6 - * MEMORY is on bus SPI2 - * MS5611 is on bus SPI4 - */ - -#define PX4_SPI_BUS_SENSORS 1 -#define PX4_SPI_BUS_MEMORY 2 -#define PX4_SPI_BUS_BARO 4 -#define PX4_SPI_BUS_EXTERNAL1 5 -#define PX4_SPI_BUS_EXTERNAL2 6 -#define PX4_SPI_BUS_SENSORS3 PX4_SPI_BUS_BARO // for BMI088 -#define PX4_SPI_BUS_EXT PX4_SPI_BUS_EXTERNAL2 -/* Define the Chip Selects, Data Ready and Control signals per SPI bus */ - -/* SPI 1 CS */ - -#define GPIO_SPI1_CS1_RM3100 /* PF2 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTF|GPIO_PIN2) -#define GPIO_SPI1_CS2_ICM20689 /* PG6 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTG|GPIO_PIN6) - -/* Define the SPI1 Data Ready interrupts */ - -#define GPIO_SPI1_DRDY1_RM3100 /* PE4 */ (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTE|GPIO_PIN4) -#define GPIO_SPI1_DRDY2_ICM20689 /* PJ0 */ (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTJ|GPIO_PIN0) - -/* SPI1 off */ - -#define GPIO_SPI1_SCK_OFF _PIN_OFF(GPIO_SPI1_SCK) -#define GPIO_SPI1_MISO_OFF _PIN_OFF(GPIO_SPI1_MISO) -#define GPIO_SPI1_MOSI_OFF _PIN_OFF(GPIO_SPI1_MOSI) - -#define GPIO_DRDY_OFF_SPI1_DRDY1_RM3100 _PIN_OFF(GPIO_SPI1_DRDY1_RM3100) -#define GPIO_DRDY_OFF_SPI1_DRDY2_ICM20689 _PIN_OFF(GPIO_SPI1_DRDY2_ICM20689) - -/* SPI 2 CS */ - -#define GPIO_SPI2_CS_FRAM /* PF5 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTF|GPIO_PIN5) - -/* SPI 4 CS */ - -#define GPIO_SPI4_CS1_MS5611 /* PG10 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTG|GPIO_PIN10) -#define GPIO_SPI4_CS2_BMI088_GYRO /* PF4 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTF|GPIO_PIN4) -#define GPIO_SPI4_CS3_BMI088_ACC /* PF3 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTF|GPIO_PIN3) - -#define GPIO_SPI4_DRDY1_BMI088_GYRO /* PB14 */ (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTB|GPIO_PIN14) -#define GPIO_SPI4_DRDY2_BMI088_ACC /* PB15 */ (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTB|GPIO_PIN15) -#define GPIO_SPI4_DRDY3_BMI088_GYRO /* PC13 */ (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTC|GPIO_PIN13) -#define GPIO_SPI4_DRDY4_BMI088_ACC /* PI14 */ (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTI|GPIO_PIN14) - - -#define GPIO_DRDY_OFF_SPI4_DRDY1_BMI088_GYRO _PIN_OFF(GPIO_SPI4_DRDY1_BMI088_GYRO) -#define GPIO_DRDY_OFF_SPI4_DRDY2_MI088_ACC _PIN_OFF(GPIO_SPI4_DRDY2_BMI088_ACC) -#define GPIO_DRDY_OFF_SPI4_DRDY3_BMI088_GYRO _PIN_OFF(GPIO_SPI4_DRDY3_BMI088_GYRO) -#define GPIO_DRDY_OFF_SPI4_DRDY4_MI088_ACC _PIN_OFF(GPIO_SPI4_DRDY4_BMI088_ACC) - -/* SPI 5 CS */ - -#define SPI5_CS1_EXTERNAL1 /* PI4 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTI|GPIO_PIN4) -#define SPI5_CS2_EXTERNAL1 /* PI10 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTI|GPIO_PIN10) - -/* Define the SPI1 Data Ready and Control signals */ - -//#define GPIO_SPI5_DRDY7_EXTERNAL1 /* PD15 */ (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTD|GPIO_PIN15) - -/* SPI 6 */ - -#define SPI6_CS1_MS5611_BOARD /* PI8 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTI|GPIO_PIN8) -#define SPI6_CS2_ICM20649 /* PI12 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTI|GPIO_PIN12) - -#define GPIO_SPI6_DRDY1_ICM20649 /* PH5 */ (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTH|GPIO_PIN5) - -#define GPIO_DRDY_OFF_SPI6_DRDY1_ICM20649 _PIN_OFF(GPIO_SPI6_DRDY1_ICM20649) - -/* - * Define the ability to shut off off the sensor signals - * by changing the signals to inputs - */ - -#define _PIN_OFF(def) (((def) & (GPIO_PORT_MASK | GPIO_PIN_MASK)) | (GPIO_INPUT|GPIO_PULLDOWN|GPIO_SPEED_2MHz)) - - -//#define GPIO_DRDY_OFF_SPI5_DRDY7_EXTERNAL1 _PIN_OFF(GPIO_SPI5_DRDY7_EXTERNAL1) - - -/* v BEGIN Legacy SPI defines TODO: fix this with enumeration */ -#define PX4_SPI_BUS_RAMTRON PX4_SPI_BUS_MEMORY -/* ^ END Legacy SPI defines TODO: fix this with enumeration */ - -#define PX4_SPIDEV_RM PX4_MK_SPI_SEL(PX4_SPI_BUS_SENSORS,0) -#define PX4_SPIDEV_ICM_20689 PX4_MK_SPI_SEL(PX4_SPI_BUS_SENSORS,1) -#define PX4_SENSOR_BUS_CS_GPIO {GPIO_SPI1_CS1_RM3100, GPIO_SPI1_CS2_ICM20689} - -#define PX4_SPIDEV_MEMORY PX4_MK_SPI_SEL(PX4_SPI_BUS_MEMORY,0) -#define PX4_MEMORY_BUS_CS_GPIO {GPIO_SPI2_CS_FRAM} - -#define PX4_SPIDEV_BARO PX4_MK_SPI_SEL(PX4_SPI_BUS_BARO,0) -#define PX4_SPIDEV_BMI088_GYR PX4_MK_SPI_SEL(PX4_SPI_BUS_BARO,1) -#define PX4_SPIDEV_BMI088_ACC PX4_MK_SPI_SEL(PX4_SPI_BUS_BARO,2) -#define PX4_BARO_BUS_CS_GPIO {GPIO_SPI4_CS1_MS5611, GPIO_SPI4_CS2_BMI088_GYRO, GPIO_SPI4_CS3_BMI088_ACC} - - -#define PX4_SPIDEV_EXTERNAL1_1 PX4_MK_SPI_SEL(PX4_SPI_BUS_EXTERNAL1,0) -#define PX4_SPIDEV_EXTERNAL1_2 PX4_MK_SPI_SEL(PX4_SPI_BUS_EXTERNAL1,1) -#define PX4_EXTERNAL1_BUS_CS_GPIO {SPI5_CS1_EXTERNAL1, SPI5_CS2_EXTERNAL1} - -#define PX4_SPIDEV_EXT_BARO PX4_MK_SPI_SEL(PX4_SPI_BUS_EXTERNAL2,0) -#define PX4_SPIDEV_ICM_20649 PX4_MK_SPI_SEL(PX4_SPI_BUS_EXTERNAL2,1) -#define PX4_SPIDEV_EXT_MPU 1//PX4_MK_SPI_SEL(PX4_SPI_BUS_EXTERNAL2,2) -#define PX4_EXTERNAL2_BUS_CS_GPIO {SPI6_CS1_MS5611_BOARD, SPI6_CS2_ICM20649} - -/* I2C busses */ - -#define PX4_I2C_BUS_EXPANSION 1 -#define PX4_I2C_BUS_EXPANSION1 2 -#define PX4_I2C_BUS_ONBOARD 3 -#define PX4_I2C_BUS_EXPANSION2 4 -#define PX4_I2C_BUS_LED PX4_I2C_BUS_EXPANSION - -#define BOARD_NUMBER_I2C_BUSES 4 -#define BOARD_I2C_BUS_CLOCK_INIT {100000, 100000, 100000, 100000} - /* * ADC channels * @@ -358,7 +224,6 @@ #define GPIO_nVDD_5V_PERIPH_OC /* PE15 */ (GPIO_INPUT |GPIO_FLOAT|GPIO_PORTE|GPIO_PIN15) #define GPIO_nVDD_5V_HIPOWER_EN /* PD11 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTD|GPIO_PIN11) #define GPIO_nVDD_5V_HIPOWER_OC /* PG13 */ (GPIO_INPUT |GPIO_FLOAT|GPIO_PORTF|GPIO_PIN13) -#define GPIO_VDD_3V3_SENSORS_EN /* PE3 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN3) //#define GPIO_VDD_3V3_SPEKTRUM_POWER_EN /* PE4 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN4) #define GPIO_VDD_3V3_SD_CARD_EN /* PG7 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTG|GPIO_PIN7) @@ -367,7 +232,6 @@ #define VDD_5V_PERIPH_EN(on_true) px4_arch_gpiowrite(GPIO_nVDD_5V_PERIPH_EN, (on_true)) #define VDD_5V_HIPOWER_EN(on_true) px4_arch_gpiowrite(GPIO_nVDD_5V_HIPOWER_EN, (on_true)) -#define VDD_3V3_SENSORS_EN(on_true) px4_arch_gpiowrite(GPIO_VDD_3V3_SENSORS_EN, (on_true)) //#define VDD_3V3_SPEKTRUM_POWER_EN(on_true) px4_arch_gpiowrite(GPIO_VDD_3V3_SPEKTRUM_POWER_EN, (on_true)) //#define READ_VDD_3V3_SPEKTRUM_POWER_EN() px4_arch_gpioread(GPIO_VDD_3V3_SPEKTRUM_POWER_EN) #define VDD_3V3_SD_CARD_EN(on_true) px4_arch_gpiowrite(GPIO_VDD_3V3_SD_CARD_EN, (on_true)) @@ -396,9 +260,6 @@ /* RC Serial port */ #define HRT_PPM_CHANNEL /* T3C1 */ 1 /* use capture/compare channel 1 */ #define GPIO_PPM_IN /* PB4 T3C1 */ GPIO_TIM3_CH1IN_2 - -/* RC Serial port */ - #define RC_SERIAL_PORT "/dev/ttyS5" #define RC_SERIAL_SINGLEWIRE @@ -531,7 +392,6 @@ GPIO_nVDD_5V_PERIPH_OC, \ GPIO_nVDD_5V_HIPOWER_EN, \ GPIO_nVDD_5V_HIPOWER_OC, \ - GPIO_VDD_3V3_SENSORS_EN, \ GPIO_VDD_3V3_SD_CARD_EN, \ GPIO_TONE_ALARM_IDLE, \ GPIO_RSSI_IN, \ @@ -578,8 +438,6 @@ int stm32_sdio_initialize(void); extern void stm32_spiinitialize(void); -void board_spi_reset(int ms); - extern void stm32_usbinitialize(void); extern void board_peripheral_reset(int ms); diff --git a/boards/cuav/nora/src/i2c.cpp b/boards/cuav/nora/src/i2c.cpp new file mode 100644 index 000000000000..63e1172b7b69 --- /dev/null +++ b/boards/cuav/nora/src/i2c.cpp @@ -0,0 +1,42 @@ +/**************************************************************************** + * + * Copyright (C) 2020 PX4 Development Team. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name PX4 nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#include + +constexpr px4_i2c_bus_t px4_i2c_buses[I2C_BUS_MAX_BUS_ITEMS] = { + initI2CBusExternal(1), + initI2CBusExternal(2), + initI2CBusInternal(3), + initI2CBusExternal(4), +}; + diff --git a/boards/cuav/nora/src/init.c b/boards/cuav/nora/src/init.c index 760c2ae22fd9..cc9010239d8d 100755 --- a/boards/cuav/nora/src/init.c +++ b/boards/cuav/nora/src/init.c @@ -105,7 +105,7 @@ __EXPORT void board_peripheral_reset(int ms) /* set the peripheral rails off */ VDD_5V_PERIPH_EN(false); - VDD_3V3_SENSORS_EN(false); + board_control_spi_sensors_power(false, 0xffff); //bool last = READ_VDD_3V3_SPEKTRUM_POWER_EN(); /* Keep Spektum on to discharge rail*/ @@ -119,7 +119,7 @@ __EXPORT void board_peripheral_reset(int ms) /* switch the peripheral rail back on */ //VDD_3V3_SPEKTRUM_POWER_EN(last); - VDD_3V3_SENSORS_EN(true); + board_control_spi_sensors_power(true, 0xffff); VDD_5V_PERIPH_EN(true); } @@ -170,9 +170,7 @@ stm32_boardinitialize(void) const uint32_t gpio[] = PX4_GPIO_INIT_LIST; px4_gpio_init(gpio, arraySize(gpio)); - /* configure SPI interfaces */ - - stm32_spiinitialize(); + board_control_spi_sensors_power_configgpio(); /* configure USB interfaces */ @@ -212,7 +210,7 @@ __EXPORT int board_app_initialize(uintptr_t arg) VDD_3V3_SD_CARD_EN(true); VDD_5V_PERIPH_EN(true); VDD_5V_HIPOWER_EN(true); - VDD_3V3_SENSORS_EN(true); + board_control_spi_sensors_power(true, 0xffff); //VDD_3V3_SPEKTRUM_POWER_EN(true); /* Need hrt running before using the ADC */ @@ -228,6 +226,10 @@ __EXPORT int board_app_initialize(uintptr_t arg) syslog(LOG_ERR, "[boot] Failed to read HW revision and version\n"); } + /* configure SPI interfaces (after we determined the HW version) */ + + stm32_spiinitialize(); + /* configure the DMA allocator */ if (board_dma_alloc_init() < 0) { diff --git a/boards/cuav/nora/src/spi.cpp b/boards/cuav/nora/src/spi.cpp old mode 100755 new mode 100644 index 929c143148f8..da08bec6bcc9 --- a/boards/cuav/nora/src/spi.cpp +++ b/boards/cuav/nora/src/spi.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * - * Copyright (C) 2012 PX4 Development Team. All rights reserved. + * Copyright (C) 2020 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -31,308 +31,33 @@ * ****************************************************************************/ -/** - * @file px4fmu_spi.c - * - * Board-specific SPI functions. - */ - -/************************************************************************************ - * Included Files - ************************************************************************************/ - -#include - -#include -#include -#include -#include - +#include +#include #include -#include -#include - -#include -#include -#include -#include "board_config.h" - -/* Define CS GPIO array */ -static constexpr uint32_t spi1selects_gpio[] = PX4_SENSOR_BUS_CS_GPIO; -static constexpr uint32_t spi2selects_gpio[] = PX4_MEMORY_BUS_CS_GPIO; -static constexpr uint32_t spi4selects_gpio[] = PX4_BARO_BUS_CS_GPIO; -static constexpr uint32_t spi5selects_gpio[] = PX4_EXTERNAL1_BUS_CS_GPIO; -static constexpr uint32_t spi6selects_gpio[] = PX4_EXTERNAL2_BUS_CS_GPIO; - -/************************************************************************************ - * Name: stm32_spiinitialize - * - * Description: - * Called to configure SPI chip select GPIO pins for the PX4FMU board. - * - ************************************************************************************/ - -__EXPORT void stm32_spiinitialize() -{ -#ifdef CONFIG_STM32H7_SPI1 - - for (auto gpio : spi1selects_gpio) { - px4_arch_configgpio(gpio); - } - -#endif // CONFIG_STM32H7_SPI1 - - -#if defined(CONFIG_STM32H7_SPI2) - - for (auto gpio : spi2selects_gpio) { - px4_arch_configgpio(gpio); - } - -#endif // CONFIG_STM32H7_SPI2 - - -#ifdef CONFIG_STM32H7_SPI4 - - for (auto gpio : spi4selects_gpio) { - px4_arch_configgpio(gpio); - } - -#endif // CONFIG_STM32H7_SPI4 - - -#ifdef CONFIG_STM32H7_SPI5 - - for (auto gpio : spi5selects_gpio) { - px4_arch_configgpio(gpio); - } - -#endif // CONFIG_STM32H7_SPI5 - - -#ifdef CONFIG_STM32H7_SPI6 - - for (auto gpio : spi6selects_gpio) { - px4_arch_configgpio(gpio); - } - -#endif // CONFIG_STM32H7_SPI6 -} - -/************************************************************************************ - * Name: stm32_spi1select and stm32_spi1status - * - * Description: - * Called by stm32 spi driver on bus 1. - * - ************************************************************************************/ -#ifdef CONFIG_STM32H7_SPI1 -__EXPORT void stm32_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected) -{ - ASSERT(PX4_SPI_BUS_ID(devid) == PX4_SPI_BUS_SENSORS); - - // Making sure the other peripherals are not selected - for (auto cs : spi1selects_gpio) { - stm32_gpiowrite(cs, 1); - } - - // SPI select is active low, so write !selected to select the device - stm32_gpiowrite(spi1selects_gpio[PX4_SPI_DEV_ID(devid)], !selected); -} - -__EXPORT uint8_t stm32_spi1status(FAR struct spi_dev_s *dev, uint32_t devid) -{ - return SPI_STATUS_PRESENT; -} -#endif // CONFIG_STM32H7_SPI1 - -/************************************************************************************ - * Name: stm32_spi2select and stm32_spi2status - * - * Description: - * Called by stm32 spi driver on bus 2. - * - ************************************************************************************/ -#if defined(CONFIG_STM32H7_SPI2) -__EXPORT void stm32_spi2select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected) -{ - if (devid == SPIDEV_FLASH(0)) { - devid = PX4_SPIDEV_MEMORY; - } - - ASSERT(PX4_SPI_BUS_ID(devid) == PX4_SPI_BUS_MEMORY); - - // Making sure the other peripherals are not selected - for (auto cs : spi2selects_gpio) { - stm32_gpiowrite(cs, 1); - } - - // SPI select is active low, so write !selected to select the device - stm32_gpiowrite(spi2selects_gpio[PX4_SPI_DEV_ID(devid)], !selected); -} - -__EXPORT uint8_t stm32_spi2status(FAR struct spi_dev_s *dev, uint32_t devid) -{ - return SPI_STATUS_PRESENT; -} -#endif // CONFIG_STM32H7_SPI2 && GPIO_SPI2_CS_FRAM - -/************************************************************************************ - * Name: stm32_spi4select and stm32_spi4status - * - * Description: - * Called by stm32 spi driver on bus 4. - * - ************************************************************************************/ -#ifdef CONFIG_STM32H7_SPI4 -__EXPORT void stm32_spi4select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected) -{ - ASSERT(PX4_SPI_BUS_ID(devid) == PX4_SPI_BUS_BARO); - - // Making sure the other peripherals are not selected - for (auto cs : spi4selects_gpio) { - stm32_gpiowrite(cs, 1); - } - - // SPI select is active low, so write !selected to select the device - stm32_gpiowrite(spi4selects_gpio[PX4_SPI_DEV_ID(devid)], !selected); -} - -__EXPORT uint8_t stm32_spi4status(FAR struct spi_dev_s *dev, uint32_t devid) -{ - return SPI_STATUS_PRESENT; -} -#endif // CONFIG_STM32H7_SPI4 - -/************************************************************************************ - * Name: stm32_spi5select and stm32_spi5status - * - * Description: - * Called by stm32 spi driver on bus 5. - * - ************************************************************************************/ -#ifdef CONFIG_STM32H7_SPI5 -__EXPORT void stm32_spi5select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected) -{ - ASSERT(PX4_SPI_BUS_ID(devid) == PX4_SPI_BUS_EXTERNAL1); - - // Making sure the other peripherals are not selected - for (auto cs : spi5selects_gpio) { - stm32_gpiowrite(cs, 1); - } - - // SPI select is active low, so write !selected to select the device - stm32_gpiowrite(spi5selects_gpio[PX4_SPI_DEV_ID(devid)], !selected); -} - -__EXPORT uint8_t stm32_spi5status(FAR struct spi_dev_s *dev, uint32_t devid) -{ - return SPI_STATUS_PRESENT; -} -#endif // CONFIG_STM32H7_SPI5 - -/************************************************************************************ - * Name: stm32_spi6select and stm32_spi6status - * - * Description: - * Called by stm32 spi driver on bus 6. - * - ************************************************************************************/ -#ifdef CONFIG_STM32H7_SPI6 -__EXPORT void stm32_spi6select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected) -{ - ASSERT(PX4_SPI_BUS_ID(devid) == PX4_SPI_BUS_EXTERNAL2); - - // Making sure the other peripherals are not selected - for (auto cs : spi6selects_gpio) { - stm32_gpiowrite(cs, 1); - } - - // SPI select is active low, so write !selected to select the device - stm32_gpiowrite(spi6selects_gpio[PX4_SPI_DEV_ID(devid)], !selected); -} - -__EXPORT uint8_t stm32_spi6status(FAR struct spi_dev_s *dev, uint32_t devid) -{ - return SPI_STATUS_PRESENT; -} -#endif // CONFIG_STM32H7_SPI6 - -/************************************************************************************ - * Name: board_spi_reset - * - * Description: - * - * - ************************************************************************************/ - -__EXPORT void board_spi_reset(int ms) -{ - // disable SPI bus - for (auto cs : spi1selects_gpio) { - stm32_configgpio(_PIN_OFF(cs)); - } - - stm32_configgpio(GPIO_SPI1_SCK_OFF); - stm32_configgpio(GPIO_SPI1_MISO_OFF); - stm32_configgpio(GPIO_SPI1_MOSI_OFF); - - -#if BOARD_USE_DRDY - // stm32_configgpio(GPIO_DRDY_OFF_SPI1_DRDY1_ICM20689); - // stm32_configgpio(GPIO_DRDY_OFF_SPI1_DRDY2_BMI088_GYRO); - // stm32_configgpio(GPIO_DRDY_OFF_SPI1_DRDY3_BMI088_ACC); - // stm32_configgpio(GPIO_DRDY_OFF_SPI1_DRDY4_ICM20602); - // stm32_configgpio(GPIO_DRDY_OFF_SPI1_DRDY5_BMI088_GYRO); - // stm32_configgpio(GPIO_DRDY_OFF_SPI1_DRDY6_BMI088_ACC); - - stm32_configgpio(GPIO_DRDY_OFF_SPI1_DRDY1_RM3100); - stm32_configgpio(GPIO_DRDY_OFF_SPI1_DRDY2_ICM20689); - stm32_configgpio(GPIO_DRDY_OFF_SPI4_DRDY1_BMI088_GYRO); - stm32_configgpio(GPIO_DRDY_OFF_SPI4_DRDY2_MI088_ACC); - stm32_configgpio(GPIO_DRDY_OFF_SPI4_DRDY3_BMI088_GYRO); - stm32_configgpio(GPIO_DRDY_OFF_SPI4_DRDY4_MI088_ACC); - stm32_configgpio(GPIO_DRDY_OFF_SPI6_DRDY1_ICM20649); - -#endif - /* set the sensor rail off */ - stm32_gpiowrite(GPIO_VDD_3V3_SENSORS_EN, 0); - - /* wait for the sensor rail to reach GND */ - usleep(ms * 1000); - syslog(LOG_DEBUG, "reset done, %d ms\n", ms); - - /* re-enable power */ - - /* switch the sensor rail back on */ - stm32_gpiowrite(GPIO_VDD_3V3_SENSORS_EN, 1); - - /* wait a bit before starting SPI, different times didn't influence results */ - usleep(100); - - /* reconfigure the SPI pins */ - for (auto cs : spi1selects_gpio) { - stm32_configgpio(cs); - } - - stm32_configgpio(GPIO_SPI1_SCK); - stm32_configgpio(GPIO_SPI1_MISO); - stm32_configgpio(GPIO_SPI1_MOSI); -#if BOARD_USE_DRDY - // stm32_configgpio(GPIO_SPI1_DRDY1_ICM20689); - // stm32_configgpio(GPIO_SPI1_DRDY2_BMI055_GYRO); - // stm32_configgpio(GPIO_SPI1_DRDY3_BMI055_ACC); - // stm32_configgpio(GPIO_SPI1_DRDY4_ICM20602); - // stm32_configgpio(GPIO_SPI1_DRDY5_BMI055_GYRO); - // stm32_configgpio(GPIO_SPI1_DRDY6_BMI055_ACC); +constexpr px4_spi_bus_t px4_spi_buses[SPI_BUS_MAX_BUS_ITEMS] = { + initSPIBus(SPI::Bus::SPI1, { + initSPIDevice(DRV_MAG_DEVTYPE_RM3100, SPI::CS{GPIO::PortF, GPIO::Pin2}, SPI::DRDY{GPIO::PortE, GPIO::Pin4}), + initSPIDevice(DRV_IMU_DEVTYPE_ICM20689, SPI::CS{GPIO::PortG, GPIO::Pin6}, SPI::DRDY{GPIO::PortJ, GPIO::Pin0}), + }, {GPIO::PortE, GPIO::Pin3}), + initSPIBus(SPI::Bus::SPI2, { + initSPIDevice(SPIDEV_FLASH(0), SPI::CS{GPIO::PortF, GPIO::Pin5}) + }), + initSPIBus(SPI::Bus::SPI4, { + initSPIDevice(DRV_BARO_DEVTYPE_MS5611, SPI::CS{GPIO::PortG, GPIO::Pin10}), + initSPIDevice(DRV_GYR_DEVTYPE_BMI088, SPI::CS{GPIO::PortF, GPIO::Pin4}, SPI::DRDY{GPIO::PortB, GPIO::Pin14}), + initSPIDevice(DRV_ACC_DEVTYPE_BMI088, SPI::CS{GPIO::PortF, GPIO::Pin3}, SPI::DRDY{GPIO::PortB, GPIO::Pin15}), + }), + initSPIBusExternal(SPI::Bus::SPI5, { + initSPIConfigExternal(SPI::CS{GPIO::PortI, GPIO::Pin4}), + initSPIConfigExternal(SPI::CS{GPIO::PortI, GPIO::Pin10}), + }), + initSPIBus(SPI::Bus::SPI6, { + initSPIDevice(DRV_BARO_DEVTYPE_MS5611, SPI::CS{GPIO::PortI, GPIO::Pin8}), + // TODO: ICM20649 + initSPIDevice(DRV_DEVTYPE_UNUSED, SPI::CS{GPIO::PortI, GPIO::Pin12}, SPI::DRDY{GPIO::PortH, GPIO::Pin5}), + }), +}; + +static constexpr bool unused = validateSPIConfig(px4_spi_buses); - stm32_configgpio(GPIO_DRDY_OFF_SPI1_DRDY1_RM3100); - stm32_configgpio(GPIO_DRDY_OFF_SPI1_DRDY2_ICM20689); - stm32_configgpio(GPIO_DRDY_OFF_SPI4_DRDY1_BMI088_GYRO); - stm32_configgpio(GPIO_DRDY_OFF_SPI4_DRDY2_MI088_ACC); - stm32_configgpio(GPIO_DRDY_OFF_SPI4_DRDY3_BMI088_GYRO); - stm32_configgpio(GPIO_DRDY_OFF_SPI4_DRDY4_MI088_ACC); - stm32_configgpio(GPIO_DRDY_OFF_SPI6_DRDY1_ICM20649); -#endif -} diff --git a/boards/cuav/nora/src/timer_config.cpp b/boards/cuav/nora/src/timer_config.cpp index 9d8f53411557..809d1c816928 100755 --- a/boards/cuav/nora/src/timer_config.cpp +++ b/boards/cuav/nora/src/timer_config.cpp @@ -38,7 +38,6 @@ constexpr io_timers_t io_timers[MAX_IO_TIMERS] = { initIOTimer(Timer::Timer5, DMA{DMA::Index1}), initIOTimer(Timer::Timer4, DMA{DMA::Index1}), - //initIOTimer(Timer::Timer8), initIOTimer(Timer::Timer1), initIOTimer(Timer::Timer12), }; diff --git a/boards/cuav/nora/stackcheck.cmake b/boards/cuav/nora/stackcheck.cmake deleted file mode 100755 index ff8267400dff..000000000000 --- a/boards/cuav/nora/stackcheck.cmake +++ /dev/null @@ -1,126 +0,0 @@ - -px4_add_board( - PLATFORM nuttx - VENDOR cuav - MODEL nora - LABEL stackcheck - TOOLCHAIN arm-none-eabi - ARCHITECTURE cortex-m7 - ROMFSROOT px4fmu_common - BUILD_BOOTLOADER - IO px4_io-v2_default - TESTING -# UAVCAN_INTERFACES 2 - No H7 or FD can support in UAVCAN - SERIAL_PORTS - GPS1:/dev/ttyS0 - TEL1:/dev/ttyS1 - TEL2:/dev/ttyS2 - TEL4:/dev/ttyS3 - DRIVERS - adc - #barometer # all available barometer drivers - barometer/ms5611 - batt_smbus - #camera_capture - #camera_trigger - differential_pressure # all available differential pressure drivers - distance_sensor # all available distance sensor drivers - #dshot - gps - heater - #imu # all available imu drivers - #imu/adis16448 - #imu/adis16477 - #imu/adis16497 - imu/bmi088 - imu/mpu6000 - #imu/mpu9250 - #irlock - #lights/blinkm - #lights/rgbled - lights/rgbled_ncp5623c - magnetometer # all available magnetometer drivers - #mkblctrl - #optical_flow # all available optical flow drivers - #osd - #pca9685 - #power_monitor/ina226 - #protocol_splitter -# pwm_input - Need to create arch/stm32 arch/stm32h7 arch/kinetis and reloacate -# all arch dependant code there - pwm_out_sim - px4fmu - px4io - #roboclaw - #tap_esc - telemetry # all available telemetry drivers - test_ppm - tone_alarm -# uavcan - No H7 or FD can support in UAVCAN yet - MODULES - airspeed_selector - #attitude_estimator_q - battery_status - #camera_feedback - commander - dataman - ekf2 - events - fw_att_control - fw_pos_control_l1 - land_detector - #landing_target_estimator - load_mon - #local_position_estimator - logger - mavlink - mc_att_control - mc_pos_control - mc_rate_control - navigator - rc_update - #rover_pos_control - sensors - #sih - temperature_compensation - vmount - vtol_att_control - SYSTEMCMDS - bl_update - config - dmesg - dumpfile - esc_calib - hardfault_log - i2cdetect - led_control - mixer - motor_ramp - motor_test - mtd - nshterm - param - perf - pwm - reboot - reflect - sd_bench - shutdown - tests # tests and test runner - top - topic_listener - tune_control - usb_connected - ver - work_queue - EXAMPLES - #bottle_drop # OBC challenge - #fixedwing_control # Tutorial code from https://px4.io/dev/example_fixedwing_control - #hello - #hwtest # Hardware test - #matlab_csv_serial - #px4_mavlink_debug # Tutorial code from http://dev.px4.io/en/debug/debug_values.html - #px4_simple_app # Tutorial code from http://dev.px4.io/en/apps/hello_sky.html - #rover_steering_control # Rover example app - #uuv_example_app - ) diff --git a/src/drivers/px4fmu/fmu.cpp b/src/drivers/px4fmu/fmu.cpp index 6ddaf9e93f62..87c9b98fcf32 100644 --- a/src/drivers/px4fmu/fmu.cpp +++ b/src/drivers/px4fmu/fmu.cpp @@ -1119,14 +1119,15 @@ PX4FMU::pwm_ioctl(file *filp, int cmd, unsigned long arg) case PWM_SERVO_SET(10): case PWM_SERVO_SET(9): case PWM_SERVO_SET(8): - // if (_mode < MODE_14PWM) { - // ret = -EINVAL; - // break; - // } + if (_mode < MODE_14PWM) { + ret = -EINVAL; + break; + } #endif #if defined(BOARD_HAS_PWM) && BOARD_HAS_PWM >= 8 + /* FALLTHROUGH */ case PWM_SERVO_SET(7): /* FALLTHROUGH */