diff --git a/arch/arm/src/stm32/stm32_sdio.c b/arch/arm/src/stm32/stm32_sdio.c index 156d233d83..206d4751ce 100644 --- a/arch/arm/src/stm32/stm32_sdio.c +++ b/arch/arm/src/stm32/stm32_sdio.c @@ -454,7 +454,7 @@ static int stm32_registercallback(FAR struct sdio_dev_s *dev, #ifdef CONFIG_SDIO_DMA static bool stm32_dmasupported(FAR struct sdio_dev_s *dev); static int stm32_dmapreflight(FAR struct sdio_dev_s *dev, - FAR uint8_t *buffer, size_t buflen); + FAR const uint8_t *buffer, size_t buflen); static int stm32_dmarecvsetup(FAR struct sdio_dev_s *dev, FAR uint8_t *buffer, size_t buflen); static int stm32_dmasendsetup(FAR struct sdio_dev_s *dev, @@ -2469,8 +2469,8 @@ static bool stm32_dmasupported(FAR struct sdio_dev_s *dev) ****************************************************************************/ #ifdef CONFIG_SDIO_DMA -static int stm32_dmapreflight(FAR struct sdio_dev_s *dev, FAR uint8_t *buffer, - size_t buflen) +static int stm32_dmapreflight(FAR struct sdio_dev_s *dev, + FAR const uint8_t *buffer, size_t buflen) { struct stm32_dev_s *priv = (struct stm32_dev_s *)dev; diff --git a/configs/nucleo-f401re/nsh/Make.defs b/configs/nucleo-f401re/nsh/Make.defs index bb9c504058..a723ed09d9 100644 --- a/configs/nucleo-f401re/nsh/Make.defs +++ b/configs/nucleo-f401re/nsh/Make.defs @@ -37,28 +37,6 @@ include ${TOPDIR}/.config include ${TOPDIR}/tools/Config.mk include ${TOPDIR}/arch/arm/src/armv7-m/Toolchain.defs -CC = $(CROSSDEV)gcc -CXX = $(CROSSDEV)g++ -CPP = $(CROSSDEV)gcc -E -LD = $(CROSSDEV)ld -AR = $(CROSSDEV)ar rcs -NM = $(CROSSDEV)nm -OBJCOPY = $(CROSSDEV)objcopy -OBJDUMP = $(CROSSDEV)objdump - -ARCHCPUFLAGS = -mcpu=cortex-m4 \ - -mthumb \ - -march=armv7e-m \ - -mfpu=fpv4-sp-d16 \ - -mfloat-abi=hard - -# Pull in *just* libm from the toolchain ... this is grody - -LIBM = "${shell $(CC) $(ARCHCPUFLAGS) -print-file-name=libm.a}" -EXTRA_LIBS += $(LIBM) - -# Use our linker script - LDSCRIPT = ld.script ifeq ($(WINTOOL),y) @@ -70,98 +48,61 @@ ifeq ($(WINTOOL),y) ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}" ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)}" else - ifeq ($(PX4_WINTOOL),y) - # Windows-native toolchains (MSYS) - DIRLINK = $(TOPDIR)/tools/copydir.sh - DIRUNLINK = $(TOPDIR)/tools/unlink.sh - MKDEP = $(TOPDIR)/tools/mknulldeps.sh - ARCHINCLUDES = -I. -isystem $(TOPDIR)/include - ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx - ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT) - else - # Linux/Cygwin-native toolchain - MKDEP = $(TOPDIR)/tools/mkdeps.sh - ARCHINCLUDES = -I. -isystem $(TOPDIR)/include - ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx - ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT) - endif + # Linux/Cygwin-native toolchain + MKDEP = $(TOPDIR)/tools/mkdeps.sh + ARCHINCLUDES = -I. -isystem $(TOPDIR)/include + ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx + ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT) endif -# Tool versions +CC = $(CROSSDEV)gcc +CXX = $(CROSSDEV)g++ +CPP = $(CROSSDEV)gcc -E +LD = $(CROSSDEV)ld +AR = $(ARCROSSDEV)ar rcs +NM = $(ARCROSSDEV)nm +OBJCOPY = $(CROSSDEV)objcopy +OBJDUMP = $(CROSSDEV)objdump 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} -# Optimization flags - -ARCHOPTIMIZATION = $(MAXOPTIMIZATION) \ - -fno-strict-aliasing \ - -fno-strength-reduce \ - -fomit-frame-pointer \ - -funsafe-math-optimizations \ - -fno-builtin-printf \ - -ffunction-sections \ - -fdata-sections - -ifeq ("${CONFIG_DEBUG_SYMBOLS}","y") -ARCHOPTIMIZATION += -g +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + ARCHOPTIMIZATION = -g endif -ARCHCFLAGS = -std=gnu99 -ARCHCXXFLAGS = -fno-exceptions -fno-rtti -std=gnu++0x -ARCHWARNINGS = -Wall \ - -Wextra \ - -Wdouble-promotion \ - -Wshadow \ - -Wfloat-equal \ - -Wframe-larger-than=1024 \ - -Wpointer-arith \ - -Wlogical-op \ - -Wmissing-declarations \ - -Wpacked \ - -Wno-unused-parameter -# -Wcast-qual - generates spurious noreturn attribute warnings, try again later -# -Wconversion - would be nice, but too many "risky-but-safe" conversions in the code -# -Wcast-align - would help catch bad casts in some cases, but generates too many false positives +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer +endif -ARCHCWARNINGS = $(ARCHWARNINGS) \ - -Wbad-function-cast \ - -Wstrict-prototypes \ - -Wold-style-declaration \ - -Wmissing-parameter-type \ - -Wmissing-prototypes \ - -Wnested-externs -ARCHWARNINGSXX = $(ARCHWARNINGS) \ - -Wno-psabi +ARCHCFLAGS = -fno-builtin +ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fno-rtti +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow +ARCHWARNINGSXX = -Wall -Wshadow ARCHDEFINES = ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 -# This seems to be the only way to add linker flags - -EXTRA_LIBS += --warn-common \ - --gc-sections - -CFLAGS = $(ARCHCFLAGS) $(ARCHCWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe -fno-common +CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) -CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(INSTRUMENTATIONDEFINES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) -CPPFLAGS = $(ARCHINCLUDES) $(INSTRUMENTATIONDEFINES) $(ARCHDEFINES) $(EXTRADEFINES) +CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) AFLAGS = $(CFLAGS) -D__ASSEMBLY__ NXFLATLDFLAGS1 = -r -d -warn-common -NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat.ld -no-check-sections +NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections LDNXFLATFLAGS = -e main -s 2048 OBJEXT = .o LIBEXT = .a EXEEXT = -# Produce partially-linked $1 from files in $2 - -define PRELINK - @echo "PRELINK: $1" - $(Q) $(LD) -Ur -o $1 $2 && $(OBJCOPY) --localize-hidden $1 -endef +ifneq ($(CROSSDEV),arm-nuttx-elf-) + LDFLAGS += -nostartfiles -nodefaultlibs +endif +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g +endif HOSTCC = gcc HOSTINCLUDES = -I. diff --git a/configs/nucleo-f401re/src/board_config.h b/configs/nucleo-f401re/src/board_config.h deleted file mode 100644 index 44262e7e51..0000000000 --- a/configs/nucleo-f401re/src/board_config.h +++ /dev/null @@ -1,265 +0,0 @@ -/**************************************************************************** - * configs/px4fmu-v2_upstream/src/board_config.h - * - * Copyright (c) 2013, 2014 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. - * - ****************************************************************************/ - -#ifndef __CONFIGS_NUCLEO_F401RE_SRC_NUCLEO_F401RE_H -#define __CONFIGS_NUCLEO_F401RE_SRC_BOARD_CONFIG_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include -#include - -#ifdef __cplusplus -__BEGIN_DECLS -#endif - -/* These headers are not C++ safe */ - -#include -#include - -#define UDID_START 0x1FFF7A10 - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ -/* Configuration ************************************************************/ - -/* PX4IO connection configuration */ - -#define PX4IO_SERIAL_DEVICE "/dev/ttyS4" -#define PX4IO_SERIAL_TX_GPIO GPIO_USART6_TX -#define PX4IO_SERIAL_RX_GPIO GPIO_USART6_RX -#define PX4IO_SERIAL_BASE STM32_USART6_BASE /* hardwired on the board */ -#define PX4IO_SERIAL_VECTOR STM32_IRQ_USART6 -#define PX4IO_SERIAL_TX_DMAMAP DMAMAP_USART6_TX_2 -#define PX4IO_SERIAL_RX_DMAMAP DMAMAP_USART6_RX_2 -#define PX4IO_SERIAL_CLOCK STM32_PCLK2_FREQUENCY -#define PX4IO_SERIAL_BITRATE 1500000 /* 1.5Mbps -> max rate for IO */ - -/* PX4FMU GPIOs *************************************************************/ -/* LEDs */ - -#define GPIO_LED1 \ - (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN12) - -/* External interrupts */ - -#define GPIO_EXTI_GYRO_DRDY (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTB|GPIO_PIN0) -#define GPIO_EXTI_MAG_DRDY (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTB|GPIO_PIN1) -#define GPIO_EXTI_ACCEL_DRDY (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTB|GPIO_PIN4) -#define GPIO_EXTI_MPU_DRDY (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTD|GPIO_PIN15) - -/* Data ready pins off */ - -#define GPIO_GYRO_DRDY_OFF (GPIO_INPUT|GPIO_PULLDOWN|GPIO_SPEED_2MHz|GPIO_PORTB|GPIO_PIN0) -#define GPIO_MAG_DRDY_OFF (GPIO_INPUT|GPIO_PULLDOWN|GPIO_SPEED_2MHz|GPIO_PORTB|GPIO_PIN1) -#define GPIO_ACCEL_DRDY_OFF (GPIO_INPUT|GPIO_PULLDOWN|GPIO_SPEED_2MHz|GPIO_PORTB|GPIO_PIN4) -#define GPIO_EXTI_MPU_DRDY_OFF (GPIO_INPUT|GPIO_PULLDOWN|GPIO_EXTI|GPIO_PORTD|GPIO_PIN15) - -/* SPI1 off */ - -#define GPIO_SPI1_SCK_OFF (GPIO_INPUT|GPIO_PULLDOWN|GPIO_PORTA|GPIO_PIN5) -#define GPIO_SPI1_MISO_OFF (GPIO_INPUT|GPIO_PULLDOWN|GPIO_PORTA|GPIO_PIN6) -#define GPIO_SPI1_MOSI_OFF (GPIO_INPUT|GPIO_PULLDOWN|GPIO_PORTA|GPIO_PIN7) - -/* SPI1 chip selects off */ - -#define GPIO_SPI_CS_GYRO_OFF \ - (GPIO_INPUT|GPIO_PULLDOWN|GPIO_SPEED_2MHz|GPIO_PORTC|GPIO_PIN13) -#define GPIO_SPI_CS_ACCEL_MAG_OFF \ - (GPIO_INPUT|GPIO_PULLDOWN|GPIO_SPEED_2MHz|GPIO_PORTC|GPIO_PIN15) -#define GPIO_SPI_CS_BARO_OFF \ - (GPIO_INPUT|GPIO_PULLDOWN|GPIO_SPEED_2MHz|GPIO_PORTD|GPIO_PIN7) -#define GPIO_SPI_CS_MPU_OFF \ - (GPIO_INPUT|GPIO_PULLDOWN|GPIO_SPEED_2MHz|GPIO_PORTC|GPIO_PIN2) - -/* SPI chip selects */ - -#define GPIO_SPI_CS_GYRO \ - (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN13) -#define GPIO_SPI_CS_ACCEL_MAG \ - (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN15) -#define GPIO_SPI_CS_BARO \ - (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTD|GPIO_PIN7) -#define GPIO_SPI_CS_FRAM \ - (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTD|GPIO_PIN10) -#define GPIO_SPI_CS_MPU \ - (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN2) - -/* Use these in place of the spi_dev_e enumeration to select a specific SPI - * device on SPI1 - */ - -#define PX4_SPIDEV_GYRO 1 -#define PX4_SPIDEV_ACCEL_MAG 2 -#define PX4_SPIDEV_BARO 3 -#define PX4_SPIDEV_MPU 4 - -/* I2C busses */ - -#define PX4_I2C_BUS_EXPANSION 1 -#define PX4_I2C_BUS_LED 2 - -/* Devices on the onboard bus. - * - * Note that these are unshifted addresses. - */ - -#define PX4_I2C_OBDEV_LED 0x55 -#define PX4_I2C_OBDEV_HMC5883 0x1e - -/* User GPIOs - * - * GPIO0-5 are the PWM servo outputs. - */ - -#define GPIO_GPIO0_INPUT (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTE|GPIO_PIN14) -#define GPIO_GPIO1_INPUT (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTE|GPIO_PIN13) -#define GPIO_GPIO2_INPUT (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTE|GPIO_PIN11) -#define GPIO_GPIO3_INPUT (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTE|GPIO_PIN9) -#define GPIO_GPIO4_INPUT (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTD|GPIO_PIN13) -#define GPIO_GPIO5_INPUT (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTD|GPIO_PIN14) -#define GPIO_GPIO0_OUTPUT \ - (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN14) -#define GPIO_GPIO1_OUTPUT \ - (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN13) -#define GPIO_GPIO2_OUTPUT \ - (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN11) -#define GPIO_GPIO3_OUTPUT \ - (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN9) -#define GPIO_GPIO4_OUTPUT \ - (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTD|GPIO_PIN13) -#define GPIO_GPIO5_OUTPUT \ - (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTD|GPIO_PIN14) - -/* Power supply control and monitoring GPIOs */ - -#define GPIO_VDD_5V_PERIPH_EN \ - (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTA|GPIO_PIN8) -#define GPIO_VDD_BRICK_VALID (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTB|GPIO_PIN5) -#define GPIO_VDD_SERVO_VALID (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTB|GPIO_PIN7) -#define GPIO_VDD_3V3_SENSORS_EN \ - (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN3) -#define GPIO_VDD_5V_HIPOWER_OC (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTE|GPIO_PIN10) -#define GPIO_VDD_5V_PERIPH_OC (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTE|GPIO_PIN15) - -/* Tone alarm output */ - -#define TONE_ALARM_TIMER 2 /* timer 2 */ -#define TONE_ALARM_CHANNEL 1 /* channel 1 */ -#define GPIO_TONE_ALARM_IDLE \ - (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTA|GPIO_PIN15) -#define GPIO_TONE_ALARM \ - (GPIO_ALT|GPIO_AF1|GPIO_SPEED_2MHz|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN15) - -/* PWM - * - * Six PWM outputs are configured. - * - * Pins: - * - * CH1 : PE14 : TIM1_CH4 - * CH2 : PE13 : TIM1_CH3 - * CH3 : PE11 : TIM1_CH2 - * CH4 : PE9 : TIM1_CH1 - * CH5 : PD13 : TIM4_CH2 - * CH6 : PD14 : TIM4_CH3 - */ - -#define GPIO_TIM1_CH1OUT GPIO_TIM1_CH1OUT_2 -#define GPIO_TIM1_CH2OUT GPIO_TIM1_CH2OUT_2 -#define GPIO_TIM1_CH3OUT GPIO_TIM1_CH3OUT_2 -#define GPIO_TIM1_CH4OUT GPIO_TIM1_CH4OUT_2 -#define GPIO_TIM4_CH2OUT GPIO_TIM4_CH2OUT_2 -#define GPIO_TIM4_CH3OUT GPIO_TIM4_CH3OUT_2 - -/* USB OTG FS - * - * PA9 OTG_FS_VBUS VBUS sensing (also connected to the green LED) - */ - -#define GPIO_OTGFS_VBUS \ - (GPIO_INPUT|GPIO_FLOAT|GPIO_SPEED_100MHz|GPIO_OPENDRAIN|GPIO_PORTA|GPIO_PIN9) - -/* High-resolution timer */ - -#define HRT_TIMER 8 /* Use timer8 for the HRT */ -#define HRT_TIMER_CHANNEL 1 /* Use capture/compare channel */ - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/**************************************************************************** - * Public data - ****************************************************************************/ - -#ifndef __ASSEMBLY__ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: stm32_spiinitialize - * - * Description: - * Called to configure SPI chip select GPIO pins for the PX4FMU board. - * - ****************************************************************************/ - -void stm32_spiinitialize(void); - -/* Ideally we'd be able to get these from up_internal.h, but since we want - * to be able to disable the NuttX use of leds for system indication at will - * and there is no separate switch, we need to build independent of the - * CONFIG_ARCH_LEDS configuration switch. - */ - -void led_init(void); -void led_on(int led); -void led_off(int led); -void led_toggle(int led); - -#endif /* __ASSEMBLY__ */ - -#ifdef __cplusplus -__END_DECLS -#endif - -#endif /* __CONFIGS_NUCLEO_F401RE_SRC_BOARD_CONFIG_H */ diff --git a/configs/nucleo-f401re/src/nucleo-f401re.h b/configs/nucleo-f401re/src/nucleo-f401re.h index 1d05bdb9d9..fc6935fe2e 100644 --- a/configs/nucleo-f401re/src/nucleo-f401re.h +++ b/configs/nucleo-f401re/src/nucleo-f401re.h @@ -14,42 +14,48 @@ #include #include -/* - The shield uses the following pins: - - +5V - GND - Digital pin 3: IRQ for WiFi - Digital pin 4: Card Select for SD card - Digital pin 5: WiFi enable - Digital pin 10: Chip Select for WiFi - Digital pins 11, 12, 13 for SPI communication (both WiFi and SD). - Digital pin 11: - Digital pin 12: - Digital pin 13: - Even if optional 6-pin SPI header is used, these pins are unavailable for other use. +/* The shield uses the following pins: + * + * +5V + * GND + * Digital pin 3: IRQ for WiFi + * Digital pin 4: Card Select for SD card + * Digital pin 5: WiFi enable + * Digital pin 10: Chip Select for WiFi + * Digital pins 11, 12, 13 for SPI communication (both WiFi and SD). + * Digital pin 11: + * Digital pin 12: + * Digital pin 13: + * Even if optional 6-pin SPI header is used, these pins are unavailable for other use. + * + * LED. User LD2: the green LED is a user LED connected to Arduino signal D13 + * corresponding to MCU I/O PA5 (pin 21) or PB13 (pin 34) depending on the STM32 + * target. + * + * - When the I/O is HIGH value, the LED is on. + * - When the I/O is LOW, the LED is off. */ #define GPIO_WIFI_INT (GPIO_PORTB | GPIO_PIN3 | GPIO_INPUT | GPIO_PULLUP | GPIO_EXTI) #define GPIO_WIFI_EN (GPIO_PORTB | GPIO_PIN4 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) #define GPIO_WIFI_CS (GPIO_PORTB | GPIO_PIN6 | GPIO_OUTPUT_SET | GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) -#define GPIO_LED1 (GPIO_PORTA | GPIO_PIN13 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) +#define GPIO_LD2 (GPIO_PORTA | GPIO_PIN13 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) #if defined(CONFIG_CC3000_PROBES) -#define GPIO_D0 (GPIO_PORTB | GPIO_PIN7 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) -#define GPIO_D1 (GPIO_PORTB | GPIO_PIN6 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) +# define GPIO_D0 (GPIO_PORTB | GPIO_PIN7 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) +# define GPIO_D1 (GPIO_PORTB | GPIO_PIN6 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) #else -#define GPIO_D0 (GPIO_PORTA | GPIO_PIN3 | GPIO_INPUT | GPIO_PULLUP | GPIO_EXTI) -#define GPIO_D1 (GPIO_PORTA | GPIO_PIN2 | GPIO_INPUT | GPIO_PULLUP | GPIO_EXTI) -#define GPIO_D2 (GPIO_PORTA | GPIO_PIN10 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) +# define GPIO_D0 (GPIO_PORTA | GPIO_PIN3 | GPIO_INPUT | GPIO_PULLUP | GPIO_EXTI) +# define GPIO_D1 (GPIO_PORTA | GPIO_PIN2 | GPIO_INPUT | GPIO_PULLUP | GPIO_EXTI) +# define GPIO_D2 (GPIO_PORTA | GPIO_PIN10 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) -#define GPIO_D8 (GPIO_PORTA | GPIO_PIN9 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) +# define GPIO_D8 (GPIO_PORTA | GPIO_PIN9 | GPIO_OUTPUT_CLEAR | GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) -#define GPIO_A0 (GPIO_PORTA | GPIO_PIN0 | GPIO_OUTPUT_SET | GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) -#define GPIO_A1 (GPIO_PORTA | GPIO_PIN1 | GPIO_OUTPUT_SET | GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) -#define GPIO_A2 (GPIO_PORTA | GPIO_PIN4 | GPIO_INPUT | GPIO_PULLUP ) -#define GPIO_A3 (GPIO_PORTB | GPIO_PIN0 | GPIO_INPUT | GPIO_PULLUP ) +# define GPIO_A0 (GPIO_PORTA | GPIO_PIN0 | GPIO_OUTPUT_SET | GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) +# define GPIO_A1 (GPIO_PORTA | GPIO_PIN1 | GPIO_OUTPUT_SET | GPIO_OUTPUT | GPIO_PULLUP | GPIO_SPEED_50MHz) +# define GPIO_A2 (GPIO_PORTA | GPIO_PIN4 | GPIO_INPUT | GPIO_PULLUP ) +# define GPIO_A3 (GPIO_PORTB | GPIO_PIN0 | GPIO_INPUT | GPIO_PULLUP ) #endif #ifndef __ASSEMBLY__ @@ -80,4 +86,3 @@ void stm32_usbinitialize(void); #endif /* __ASSEMBLY__ */ #endif /* __CONFIGS_NUCLEO_F401RE_SRC_NUCLEO_F401RE_H */ - diff --git a/configs/nucleo-f401re/src/stm32_boot.c b/configs/nucleo-f401re/src/stm32_boot.c index 8a09263cf6..ca22088fee 100644 --- a/configs/nucleo-f401re/src/stm32_boot.c +++ b/configs/nucleo-f401re/src/stm32_boot.c @@ -92,7 +92,6 @@ void stm32_boardinitialize(void) stm32_spiinitialize(); #endif - /* Initialize USB is 1) USBDEV is selected, 2) the USB controller is not * disabled, and 3) the weak function stm32_usbinitialize() has been brought * into the build. @@ -125,8 +124,8 @@ void board_initialize(void) */ #if defined(CONFIG_NSH_LIBRARY) && !defined(CONFIG_NSH_ARCHINIT) - nsh_archinitialize(); - wireless_archinitialize(0); + nsh_archinitialize(); + wireless_archinitialize(0); #endif } #endif diff --git a/configs/nucleo-f401re/src/stm32_init.c b/configs/nucleo-f401re/src/stm32_init.c index 27a8b91bc1..196cb133a8 100644 --- a/configs/nucleo-f401re/src/stm32_init.c +++ b/configs/nucleo-f401re/src/stm32_init.c @@ -1,13 +1,8 @@ /**************************************************************************** * configs/nucleo-f401re/src/stm32_init.c * - * PX4FMU-specific early startup code. This file implements the - * nsh_archinitialize() function that is called early by nsh during startup. - * - * Code here is run before the rcS script is invoked; it should start - * required subsystems and perform board-specific initialisation. - * - * Copyright (C) 2012 PX4 Development Team. All rights reserved. + * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -19,7 +14,7 @@ * 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 + * 3. Neither the name NuttX nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * @@ -59,7 +54,6 @@ #include #include -#include "board_config.h" #include #include @@ -71,18 +65,11 @@ /* Configuration ************************************************************/ #ifdef CONFIG_FAT_DMAMEMORY -# if !defined(CONFIG_GRAN) || !defined(CONFIG_FAT_DMAMEMORY) -# error microSD DMA support requires CONFIG_GRAN -# endif +# if !defined(CONFIG_GRAN) || !defined(CONFIG_FAT_DMAMEMORY) +# error microSD DMA support requires CONFIG_GRAN +# endif #endif -/* PX4 LED colour codes */ - -#define LED_AMBER 1 -#define LED_RED 1 /* Some boards have red rather than amber */ -#define LED_BLUE 0 -#define LED_SAFETY 2 - /* Debug ********************************************************************/ #ifdef CONFIG_CPP_HAVE_VARARGS @@ -109,7 +96,7 @@ static GRAN_HANDLE dma_allocator; /* The DMA heap size constrains the total number of things that can be * ready to do DMA at a time. * - * For example, FAT DMA depends on one sector-sized buffer per filesystem plus + * For example, FAT DMA depends on one sector-sized buffer per file system plus * one sector-sized buffer per file. * * We use a fundamental alignment / granule size of 64B; this is sufficient @@ -120,7 +107,6 @@ static uint8_t g_dma_heap[8192] __attribute__((aligned(64))); #endif static struct spi_dev_s *spi1; -static struct spi_dev_s *spi2; static struct sdio_dev_s *sdio; /**************************************************************************** @@ -149,21 +135,6 @@ static void dma_alloc_init(void) * Public Functions ****************************************************************************/ -#ifdef CONFIG_FAT_DMAMEMORY -/* DMA-aware allocator stubs for the FAT filesystem. */ - -void *fat_dma_alloc(size_t size) -{ - return gran_alloc(dma_allocator, size); -} - -void fat_dma_free(FAR void *memory, size_t size) -{ - gran_free(dma_allocator, memory, size); -} - -#endif - void up_netinitialize(void) { } @@ -182,41 +153,12 @@ int nsh_archinitialize(void) int ret; #endif - /* Configure ADC pins */ - - stm32_configgpio(GPIO_ADC1_IN2); /* BATT_VOLTAGE_SENS */ - stm32_configgpio(GPIO_ADC1_IN3); /* BATT_CURRENT_SENS */ - stm32_configgpio(GPIO_ADC1_IN4); /* VDD_5V_SENS */ -//stm32_configgpio(GPIO_ADC1_IN10); /* used by VBUS valid */ -//stm32_configgpio(GPIO_ADC1_IN11); /* unused */ -//stm32_configgpio(GPIO_ADC1_IN12); /* used by MPU6000 CS */ - stm32_configgpio(GPIO_ADC1_IN13); /* FMU_AUX_ADC_1 */ - stm32_configgpio(GPIO_ADC1_IN14); /* FMU_AUX_ADC_2 */ - stm32_configgpio(GPIO_ADC1_IN15); /* PRESSURE_SENS */ - - /* Configure power supply control/sense pins */ - - stm32_configgpio(GPIO_VDD_5V_PERIPH_EN); - stm32_configgpio(GPIO_VDD_3V3_SENSORS_EN); - stm32_configgpio(GPIO_VDD_BRICK_VALID); - stm32_configgpio(GPIO_VDD_SERVO_VALID); - stm32_configgpio(GPIO_VDD_5V_HIPOWER_OC); - stm32_configgpio(GPIO_VDD_5V_PERIPH_OC); - - /* Configure the DMA allocator */ - - dma_alloc_init(); - /* Configure CPU load estimation */ #ifdef CONFIG_SCHED_INSTRUMENTATION cpuload_initialize_once(); #endif - /* Initial LED state */ - - led_off(LED_AMBER); - /* Configure SPI-based devices */ spi1 = up_spiinitialize(1); @@ -227,42 +169,6 @@ int nsh_archinitialize(void) return -ENODEV; } - /* Default SPI1 to 1MHz and de-assert the known chip selects. */ - - SPI_SETFREQUENCY(spi1, 10000000); - SPI_SETBITS(spi1, 8); - SPI_SETMODE(spi1, SPIDEV_MODE3); - SPI_SELECT(spi1, PX4_SPIDEV_GYRO, false); - SPI_SELECT(spi1, PX4_SPIDEV_ACCEL_MAG, false); - SPI_SELECT(spi1, PX4_SPIDEV_BARO, false); - SPI_SELECT(spi1, PX4_SPIDEV_MPU, false); - up_udelay(20); - - message("[boot] Initialized SPI port 1 (SENSORS)\n"); - - /* Get the SPI port for the FRAM */ - - spi2 = up_spiinitialize(2); - if (!spi2) - { - message("[boot] FAILED to initialize SPI port 2\n"); - board_led_on(LED_AMBER); - return -ENODEV; - } - - /* Default SPI2 to 37.5 MHz (40 MHz rounded to nearest valid divider, F4 max) - * and de-assert the known chip selects. - */ - - // XXX start with 10.4 MHz in FRAM usage and go up to 37.5 once validated - - SPI_SETFREQUENCY(spi2, 12 * 1000 * 1000); - SPI_SETBITS(spi2, 8); - SPI_SETMODE(spi2, SPIDEV_MODE3); - SPI_SELECT(spi2, SPIDEV_FLASH, false); - - message("[boot] Initialized SPI port 2 (RAMTRON FRAM)\n"); - #ifdef CONFIG_MMCSD /* First, get an instance of the SDIO interface */ @@ -279,7 +185,7 @@ int nsh_archinitialize(void) ret = mmcsd_slotinitialize(CONFIG_NSH_MMCSDMINOR, sdio); if (ret != OK) { - message("[boot] Failed to bind SDIO to the MMC/SD driver: %d\n", ret); + message("ERROR: Failed to bind SDIO to the MMC/SD driver: %d\n", ret); return ret; } diff --git a/configs/nucleo-f401re/src/stm32_led.c b/configs/nucleo-f401re/src/stm32_led.c index 8c890d5937..2ac49740da 100644 --- a/configs/nucleo-f401re/src/stm32_led.c +++ b/configs/nucleo-f401re/src/stm32_led.c @@ -1,7 +1,8 @@ /**************************************************************************** * configs/nucleo-f401re/src/stm32_led.c * - * Copyright (c) 2013 PX4 Development Team. All rights reserved. + * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -13,7 +14,7 @@ * 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 + * 3. Neither the name NuttX nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,20 +41,20 @@ #include -#include "stm32.h" -#include "board_config.h" - #include +#include "stm32.h" +#include "nucleo-f401re.h" + /**************************************************************************** * Public Functions ****************************************************************************/ -void led_init() +void led_init(void) { /* Configure LED1 GPIO for output */ - stm32_configgpio(GPIO_LED1); + stm32_configgpio(GPIO_LD2); } void led_on(int led) @@ -62,7 +63,7 @@ void led_on(int led) { /* Pull down to switch on */ - stm32_gpiowrite(GPIO_LED1, false); + stm32_gpiowrite(GPIO_LD2, true); } } @@ -72,7 +73,7 @@ void led_off(int led) { /* Pull up to switch off */ - stm32_gpiowrite(GPIO_LED1, true); + stm32_gpiowrite(GPIO_LD2, false); } } @@ -80,13 +81,13 @@ void led_toggle(int led) { if (led == 1) { - if (stm32_gpioread(GPIO_LED1)) + if (stm32_gpioread(GPIO_LD2)) { - stm32_gpiowrite(GPIO_LED1, false); + stm32_gpiowrite(GPIO_LD2, false); } else { - stm32_gpiowrite(GPIO_LED1, true); + stm32_gpiowrite(GPIO_LD2, true); } } } diff --git a/configs/nucleo-f401re/src/stm32_spi.c b/configs/nucleo-f401re/src/stm32_spi.c index 05001aa478..6118b81d0d 100644 --- a/configs/nucleo-f401re/src/stm32_spi.c +++ b/configs/nucleo-f401re/src/stm32_spi.c @@ -1,7 +1,8 @@ /**************************************************************************** * configs/nucleo-f401re/src/stm32_spi.c * - * Copyright (C) 2012 PX4 Development Team. All rights reserved. + * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -13,7 +14,7 @@ * 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 + * 3. Neither the name NuttX nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * @@ -49,7 +50,6 @@ #include #include -#include "board_config.h" #include "nucleo-f401re.h" #if defined(CONFIG_STM32_SPI1) || defined(CONFIG_STM32_SPI2) || defined(CONFIG_STM32_SPI3) @@ -85,35 +85,16 @@ * Name: stm32_spiinitialize * * Description: - * Called to configure SPI chip select GPIO pins for the PX4FMU board. + * Called to configure SPI chip select GPIO pins for the Nucleo-F401RE board. * ************************************************************************************/ void weak_function stm32_spiinitialize(void) { #ifdef CONFIG_STM32_SPI1 - stm32_configgpio(GPIO_SPI_CS_GYRO); - stm32_configgpio(GPIO_SPI_CS_ACCEL_MAG); - stm32_configgpio(GPIO_SPI_CS_BARO); - stm32_configgpio(GPIO_SPI_CS_MPU); - - /* De-activate all peripherals, required for some peripheral state machines */ - - stm32_gpiowrite(GPIO_SPI_CS_GYRO, 1); - stm32_gpiowrite(GPIO_SPI_CS_ACCEL_MAG, 1); - stm32_gpiowrite(GPIO_SPI_CS_BARO, 1); - stm32_gpiowrite(GPIO_SPI_CS_MPU, 1); - - stm32_configgpio(GPIO_EXTI_GYRO_DRDY); - stm32_configgpio(GPIO_EXTI_MAG_DRDY); - stm32_configgpio(GPIO_EXTI_ACCEL_DRDY); - stm32_configgpio(GPIO_EXTI_MPU_DRDY); #endif #ifdef CONFIG_STM32_SPI2 - stm32_configgpio(GPIO_SPI_CS_FRAM); - stm32_gpiowrite(GPIO_SPI_CS_FRAM, 1); - /* Setup CS, EN & IRQ line IOs */ #ifdef CONFIG_WL_CC3000 @@ -121,10 +102,6 @@ void weak_function stm32_spiinitialize(void) stm32_configgpio(GPIO_WIFI_EN); stm32_configgpio(GPIO_WIFI_INT); #endif - -#ifdef CONFIG_MTD_SST25 - stm32_configgpio(GPIO_MEM_CS); /* FLASH chip select */ -#endif #endif } @@ -157,50 +134,6 @@ void weak_function stm32_spiinitialize(void) void stm32_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected) { spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); - - /* SPI select is active low, so write !selected to select the device */ - - switch (devid) - { - case PX4_SPIDEV_GYRO: - /* Making sure the other peripherals are not selected */ - - stm32_gpiowrite(GPIO_SPI_CS_GYRO, !selected); - stm32_gpiowrite(GPIO_SPI_CS_ACCEL_MAG, 1); - stm32_gpiowrite(GPIO_SPI_CS_BARO, 1); - stm32_gpiowrite(GPIO_SPI_CS_MPU, 1); - break; - - case PX4_SPIDEV_ACCEL_MAG: - /* Making sure the other peripherals are not selected */ - - stm32_gpiowrite(GPIO_SPI_CS_GYRO, 1); - stm32_gpiowrite(GPIO_SPI_CS_ACCEL_MAG, !selected); - stm32_gpiowrite(GPIO_SPI_CS_BARO, 1); - stm32_gpiowrite(GPIO_SPI_CS_MPU, 1); - break; - - case PX4_SPIDEV_BARO: - /* Making sure the other peripherals are not selected */ - - stm32_gpiowrite(GPIO_SPI_CS_GYRO, 1); - stm32_gpiowrite(GPIO_SPI_CS_ACCEL_MAG, 1); - stm32_gpiowrite(GPIO_SPI_CS_BARO, !selected); - stm32_gpiowrite(GPIO_SPI_CS_MPU, 1); - break; - - case PX4_SPIDEV_MPU: - /* Making sure the other peripherals are not selected */ - - stm32_gpiowrite(GPIO_SPI_CS_GYRO, 1); - stm32_gpiowrite(GPIO_SPI_CS_ACCEL_MAG, 1); - stm32_gpiowrite(GPIO_SPI_CS_BARO, 1); - stm32_gpiowrite(GPIO_SPI_CS_MPU, !selected); - break; - - default: - break; - } } uint8_t stm32_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid) @@ -214,27 +147,12 @@ void stm32_spi2select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool sele { spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); -#if defined(CONFIG_MTD_SST25) - - if (devid == SPIDEV_FLASH) - { - stm32_gpiowrite(GPIO_MEM_CS, !selected); - } - else -#endif - #if defined(CONFIG_WL_CC3000) if (devid == SPIDEV_WIRELESS) { stm32_gpiowrite(GPIO_WIFI_CS, !selected); } - else #endif - { - /* There can only be one device on this bus, so always select it */ - - stm32_gpiowrite(GPIO_SPI_CS_FRAM, !selected); - } } uint8_t stm32_spi2status(FAR struct spi_dev_s *dev, enum spi_dev_e devid) @@ -282,7 +200,7 @@ uint8_t stm32_spi3status(FAR struct spi_dev_s *dev, enum spi_dev_e devid) #ifdef CONFIG_STM32_SPI1 int stm32_spi1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd) { - return -ENODEV; + return OK; } #endif diff --git a/configs/nucleo-f401re/src/stm32_wireless.c b/configs/nucleo-f401re/src/stm32_wireless.c index 7b83bc0ba0..139b60e521 100644 --- a/configs/nucleo-f401re/src/stm32_wireless.c +++ b/configs/nucleo-f401re/src/stm32_wireless.c @@ -268,7 +268,6 @@ static bool probe(FAR struct cc3000_config_s *state,int n, bool s) * configure the wireless device. This function will register the driver * as /dev/wirelessN where N is the minor device number. * - * * Returned Value: * Zero is returned on success. Otherwise, a negated errno value is * returned to indicate the nature of the failure. diff --git a/drivers/wireless/cc3000/cc3000.c b/drivers/wireless/cc3000/cc3000.c index 86ac378abe..40394aad27 100644 --- a/drivers/wireless/cc3000/cc3000.c +++ b/drivers/wireless/cc3000/cc3000.c @@ -610,18 +610,10 @@ static void * select_thread_func(FAR void *arg) static void * cc3000_worker(FAR void *arg) { - FAR struct cc3000_dev_s *priv = (FAR struct cc3000_dev_s *)arg; - FAR struct cc3000_config_s *config; - int ret; + FAR struct cc3000_dev_s *priv = (FAR struct cc3000_dev_s *)arg; + int ret; - ASSERT(priv != NULL); - - /* Get a pointer the callbacks for convenience (and so the code is not so - * ugly). - */ - - config = priv->config; - DEBUGASSERT(config != NULL); + ASSERT(priv != NULL && priv->config != NULL); /* We have started release our creator*/ @@ -705,7 +697,8 @@ static void * cc3000_worker(FAR void *arg) priv->rx_buffer.len = data_to_recv; ret = mq_send(priv->queue, &priv->rx_buffer, sizeof(priv->rx_buffer), 1); - DEBUGASSERT(ret>=0); + DEBUGASSERT(ret >= 0); + UNUSED(ret); /* Notify any waiters that new CC3000 data is available */ @@ -714,9 +707,11 @@ static void * cc3000_worker(FAR void *arg) /* Give up driver */ cc3000_devgive(priv); + nllvdbg("Wait On Completion\n"); sem_wait(priv->wrkwaitsem); - nllvdbg("Completed S:%d irq :%d\n",priv->state,priv->config->irq_read(priv->config)); + nllvdbg("Completed S:%d irq :%d\n", + priv->state, priv->config->irq_read(priv->config)); sem_getvalue(&priv->irqsem, &count); if (priv->config->irq_read(priv->config) && count==0) @@ -731,17 +726,17 @@ static void * cc3000_worker(FAR void *arg) continue; } - } /* eSPI_STATE_WRITE_DONE or eSPI_STATE_IDLE */ + } break; default: nllvdbg("default: State%d\n",priv->state); break; - } /* end switch */ - } /* end if */ + } + } cc3000_devgive(priv); - } /* while (1) */ + } return OK; } diff --git a/drivers/wireless/cc3000/cc3000.h b/drivers/wireless/cc3000/cc3000.h index 703dc435b9..630f217946 100644 --- a/drivers/wireless/cc3000/cc3000.h +++ b/drivers/wireless/cc3000/cc3000.h @@ -92,7 +92,9 @@ #ifdef CONFIG_CC3000_MT /* lock to serialze access to driver (spi protocol is window size 1) */ + extern pthread_mutex_t g_cc3000_mut; + /* This structure describes the state of one CC3000 driver instance */ typedef struct cc3000_socket_ent @@ -185,6 +187,7 @@ static inline void cc3000_lib_lock(void) #ifdef CONFIG_CC3000_MT int status = pthread_mutex_lock(&g_cc3000_mut); DEBUGASSERT(status == 0); + UNUSED(status); #endif } @@ -193,6 +196,7 @@ static inline void cc3000_lib_unlock(void) #ifdef CONFIG_CC3000_MT int status = pthread_mutex_unlock(&g_cc3000_mut); DEBUGASSERT(status == 0); + UNUSED(status); #endif } diff --git a/drivers/wireless/cc3000/cc3000drv.c b/drivers/wireless/cc3000/cc3000drv.c index f0ade37d11..d8921fdadd 100644 --- a/drivers/wireless/cc3000/cc3000drv.c +++ b/drivers/wireless/cc3000/cc3000drv.c @@ -264,6 +264,7 @@ void cc3000_open(gcSpiHandleRx pfRxHandler) status = pthread_create(&spiconf.unsoliced_thread, &attr, unsoliced_thread_func, NULL); DEBUGASSERT(status == 0) + UNUSED(status); } DEBUGASSERT(spiconf.cc3000fd); diff --git a/drivers/wireless/cc3000/evnt_handler.c b/drivers/wireless/cc3000/evnt_handler.c index 82c2f85d3c..28901e3c39 100644 --- a/drivers/wireless/cc3000/evnt_handler.c +++ b/drivers/wireless/cc3000/evnt_handler.c @@ -895,7 +895,7 @@ void update_socket_active_status(char *resp_params) * opcode in a global variable. * * Input Parameters: - * usOpcode command operation code + * opcode command operation code * pRetParams command return parameters * * Returned Value: @@ -903,14 +903,14 @@ void update_socket_active_status(char *resp_params) * *****************************************************************************/ -void SimpleLinkWaitEvent(uint16_t usOpcode, void *pRetParams) +void SimpleLinkWaitEvent(uint16_t opcode, void *pRetParams) { /* In the blocking implementation the control to caller will be returned only * after the end of current transaction */ - tSLInformation.usRxEventOpcode = usOpcode; - nllvdbg("Looking for usOpcode 0x%x\n",usOpcode); + tSLInformation.usRxEventOpcode = opcode; + nllvdbg("Looking for opcode 0x%x\n",opcode); uint16_t event_type; do @@ -925,22 +925,22 @@ void SimpleLinkWaitEvent(uint16_t usOpcode, void *pRetParams) nllvdbg("Evtn:0x%x\n",event_type); } - if (event_type != usOpcode) + if (event_type != opcode) { if (hci_unsolicited_event_handler() == 1) { - nllvdbg("Processed Event 0x%x want 0x%x\n",event_type, usOpcode); + nllvdbg("Processed Event 0x%x want 0x%x\n",event_type, opcode); } } else { - nllvdbg("Processing usOpcode 0x%x\n",usOpcode); + nllvdbg("Processing opcode 0x%x\n",opcode); hci_event_handler(pRetParams, 0, 0); } } while (tSLInformation.usRxEventOpcode != 0); - nllvdbg("Done for usOpcode 0x%x\n",usOpcode); + nllvdbg("Done for opcode 0x%x\n",opcode); } /***************************************************************************** @@ -968,7 +968,7 @@ void SimpleLinkWaitData(uint8_t *pBuf, uint8_t *from, uint8_t *fromlen) nllvdbg("Looking for Data\n"); uint16_t event_type; - uint16_t usOpcode = tSLInformation.usRxEventOpcode; + uint16_t opcode = tSLInformation.usRxEventOpcode; do { @@ -983,20 +983,23 @@ void SimpleLinkWaitData(uint8_t *pBuf, uint8_t *from, uint8_t *fromlen) } else { - STREAM_TO_UINT16((char *)tSLInformation.pucReceivedData, HCI_EVENT_OPCODE_OFFSET,event_type); - nllvdbg("Evtn:0x%x\n",event_type); + STREAM_TO_UINT16((char *)tSLInformation.pucReceivedData, HCI_EVENT_OPCODE_OFFSET, event_type); + nllvdbg("Evtn:0x%x\n", event_type); if (hci_unsolicited_event_handler() == 1) { - nllvdbg("Processed Event 0x%x want Data! Opcode 0x%x\n",event_type, usOpcode); + nllvdbg("Processed Event 0x%x want Data! Opcode 0x%x\n", event_type, opcode); } else { - nllvdbg("!!!!!usOpcode 0x%x\n",usOpcode); + nllvdbg("!!!!!opcode 0x%x\n",opcode); } + + UNUSED(event_type); } } while (*tSLInformation.pucReceivedData == HCI_TYPE_EVNT); - nllvdbg("Done for Data 0x%x\n",usOpcode); + nllvdbg("Done for Data 0x%x\n", opcode); + UNUSED(opcode); } diff --git a/drivers/wireless/cc3000/wlan.c b/drivers/wireless/cc3000/wlan.c index 08356d322e..dd41b67a44 100644 --- a/drivers/wireless/cc3000/wlan.c +++ b/drivers/wireless/cc3000/wlan.c @@ -236,12 +236,16 @@ void wlan_init(size_t max_tx_len, void SpiReceiveHandler(void *pvBuffer) { + uint16_t event_type; + tSLInformation.pucReceivedData = (uint8_t *)pvBuffer; tSLInformation.usEventOrDataReceived = 1; - uint16_t event_type; - STREAM_TO_UINT16((char *)tSLInformation.pucReceivedData, HCI_EVENT_OPCODE_OFFSET,event_type); - nllvdbg("Evtn:0x%x\n", event_type); + STREAM_TO_UINT16((char *)tSLInformation.pucReceivedData, + HCI_EVENT_OPCODE_OFFSET, event_type); + + nllvdbg("Evnt:0x%x\n", event_type); + UNUSED(event_type); hci_unsolicited_event_handler(); } diff --git a/include/nuttx/sdio.h b/include/nuttx/sdio.h index 5c823f3a15..fd74eecc3a 100644 --- a/include/nuttx/sdio.h +++ b/include/nuttx/sdio.h @@ -872,13 +872,13 @@ struct sdio_dev_s #ifdef CONFIG_SDIO_DMA bool (*dmasupported)(FAR struct sdio_dev_s *dev); #ifdef CONFIG_SDIO_PREFLIGHT - int (*dmapreflight)(FAR struct sdio_dev_s *dev, FAR uint8_t *buffer, - size_t buflen); + int (*dmapreflight)(FAR struct sdio_dev_s *dev, + FAR const uint8_t *buffer, size_t buflen); #endif int (*dmarecvsetup)(FAR struct sdio_dev_s *dev, FAR uint8_t *buffer, size_t buflen); - int (*dmasendsetup)(FAR struct sdio_dev_s *dev, FAR const uint8_t *buffer, - size_t buflen); + int (*dmasendsetup)(FAR struct sdio_dev_s *dev, + FAR const uint8_t *buffer, size_t buflen); #endif }; diff --git a/libc/stdio/lib_libdtoa.c b/libc/stdio/lib_libdtoa.c index 7fc8369bce..a2edecf6b5 100644 --- a/libc/stdio/lib_libdtoa.c +++ b/libc/stdio/lib_libdtoa.c @@ -150,7 +150,6 @@ static void lib_dtoa(FAR struct lib_outstream_s *obj, int fmt, int prec, uint8_t flags, double value) { FAR char *digits; /* String returned by __dtoa */ - FAR char *digalloc; /* Copy of digits to be freed after usage */ FAR char *rve; /* Points to the end of the return value */ int expt; /* Integer value of exponent */ int numlen; /* Actual number of digits returned by cvt */ @@ -188,7 +187,6 @@ static void lib_dtoa(FAR struct lib_outstream_s *obj, int fmt, int prec, /* Perform the conversion */ digits = __dtoa(value, 3, prec, &expt, &dsgn, &rve); - digalloc = digits; numlen = rve - digits; if (IS_NEGATE(flags)) @@ -318,7 +316,7 @@ static void lib_dtoa(FAR struct lib_outstream_s *obj, int fmt, int prec, digits++; } - /* Decremnt to get the number of trailing zeroes to print */ + /* Decrement to get the number of trailing zeroes to print */ prec -= nchars; } @@ -326,15 +324,6 @@ static void lib_dtoa(FAR struct lib_outstream_s *obj, int fmt, int prec, /* Finally, print any trailing zeroes */ zeroes(obj, prec); - - /* Is this memory supposed to be freed or not? */ - -#if 0 - if (digalloc) - { - lib_free(digalloc); - } -#endif } /****************************************************************************