diff --git a/configs/olimex-stm32-e407/README.txt b/configs/olimex-stm32-e407/README.txt index 0b6e02eee73..ccb3cbcf985 100644 --- a/configs/olimex-stm32-e407/README.txt +++ b/configs/olimex-stm32-e407/README.txt @@ -2,5 +2,75 @@ README ====== The Olimex STM32-E407 configuration is based on the configuration olimex-stm32-h407 and stm32f4discovery. -nsh - Basic shell run on USART2. -usbnsh - Basic shell run on the virtual serial port. +Configurations +============== + + Instantiating Configurations + ---------------------------- + Each Olimex-STM32-E407 configuration is maintained in a sub-directory and + can be selected as follow: + + tools/configure.sh olimex-stm32-e407/ + + Where is one of the following: + + Compile Firmware + ---------------- + Once you've set the proper configuration, you just need to execute the next + command: + + make + + If everything goes find, it should return the next two files: + + nuttx.hex + nuttx.bin + + You can return more kind of files by setting on menuconfig. + + + Flashing the Board + ----------------- + You can flash this board in different ways, but the easiest way is using + ARM-USB-TINY-H JTAG flasher device. + Connect this device to the JTAG connector and type the next command: + + openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f target/stm32f4x.cfg -c init -c "reset halt" -c "flash write_image erase nuttx.bin 0x08000000" + + Configuration Directories + ------------------------- + nsh: + --- + Configures the NuttShell (nsh) located at apps/examples/nsh. This + configuration enables a console on UART2. Support for + builtin applications is enabled, but in the base configuration no + builtin applications are selected. + + usbnsh: + ------ + Configures the NuttShell (nsh) located at apps/examples/nsh. This + configuration enables a console on USB_OTG1. Support for + builtin applications is enabled, but in the base configuration no + builtin applications are selected. + + netnsh: + ------ + Configures the NuttShell (nsh) located at examples/nsh. This + configuration is focused on network testing. + + BMP180: + ------ + This a configuration example for the BMP180 barometer sensor. This + sensor works with I2C, you need to do the next connections: + + BMP180 VIN -> Board 3.3V + BMP180 GND -> Board GND + BMP180 SCL -> Board PB6 (Arduino header D1) + BMP180 SDA -> Board PB7 (Arduino header D0) + + This example is configured to work with the USBNSH instead of UART NSH, so + the console will be shown over the USB_OTG1 connector. + + On the console, type "ls /dev " and if the registration process goes fine, + you should see a device called "press0". Now execute the app + BMP180 to see the ambient pressure value. diff --git a/configs/olimex-stm32-e407/bmp180/defconfig b/configs/olimex-stm32-e407/bmp180/defconfig new file mode 100644 index 00000000000..f6b5557bb82 --- /dev/null +++ b/configs/olimex-stm32-e407/bmp180/defconfig @@ -0,0 +1,65 @@ +# +# 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_ARCH_FPU is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_NSH_CMDPARMS is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="olimex-stm32-e407" +CONFIG_ARCH_BOARD_OLIMEX_STM32E407=y +CONFIG_ARCH_BUTTONS=y +CONFIG_ARCH_CHIP_STM32=y +CONFIG_ARCH_CHIP_STM32F407ZG=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARDCTL_USBDEVCTRL=y +CONFIG_BOARD_LATE_INITIALIZE=y +CONFIG_BOARD_LOOPSPERMSEC=16717 +CONFIG_BUILTIN=y +CONFIG_CDCACM=y +CONFIG_CDCACM_CONSOLE=y +CONFIG_EXAMPLES_BMP180=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_FS_PROCFS=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_INTELHEX_BINARY=y +CONFIG_LIB_BOARDCTL=y +CONFIG_MAX_TASKS=16 +CONFIG_MAX_WDOGPARMS=2 +CONFIG_MM_REGIONS=2 +CONFIG_NFILE_DESCRIPTORS=8 +CONFIG_NFILE_STREAMS=8 +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_MQ_MSGS=4 +CONFIG_PREALLOC_TIMERS=4 +CONFIG_PREALLOC_WDOGS=16 +CONFIG_RAM_SIZE=114688 +CONFIG_RAM_START=0x20000000 +CONFIG_RAW_BINARY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_SDCLONE_DISABLE=y +CONFIG_SENSORS=y +CONFIG_SENSORS_BMP180=y +CONFIG_START_DAY=6 +CONFIG_START_MONTH=12 +CONFIG_START_YEAR=2011 +CONFIG_STM32_I2C1=y +CONFIG_STM32_JTAG_SW_ENABLE=y +CONFIG_STM32_OTGFS=y +CONFIG_STM32_PWR=y +CONFIG_STM32_USART2=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_NSH_CXXINITIALIZE=y +CONFIG_USART2_RXBUFSIZE=128 +CONFIG_USART2_TXBUFSIZE=128 +CONFIG_USBDEV=y +CONFIG_USER_ENTRYPOINT="nsh_main" diff --git a/configs/olimex-stm32-e407/src/Makefile b/configs/olimex-stm32-e407/src/Makefile index a776c03ad20..44defad9d74 100644 --- a/configs/olimex-stm32-e407/src/Makefile +++ b/configs/olimex-stm32-e407/src/Makefile @@ -80,5 +80,9 @@ ifeq ($(CONFIG_ARCH_FPU),y) CSRCS += stm32_ostest.c endif +ifeq ($(CONFIG_SENSORS_BMP180),y) +CSRCS += stm32_bmp180.c +endif + include $(TOPDIR)/configs/Board.mk diff --git a/configs/olimex-stm32-e407/src/olimex-stm32-e407.h b/configs/olimex-stm32-e407/src/olimex-stm32-e407.h index bbc73d71b3e..af7ef82633e 100644 --- a/configs/olimex-stm32-e407/src/olimex-stm32-e407.h +++ b/configs/olimex-stm32-e407/src/olimex-stm32-e407.h @@ -269,5 +269,23 @@ int stm32_sdio_initialize(void); int stm32_can_setup(void); #endif +/************************************************************************************ + * Name: stm32_bmp180initialize + * + * Description: + * Initialize and register the BMP180 Pressure Sensor driver. + * + * Input parameters: + * devpath - The full path to the driver to register. E.g., "/dev/press0" + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ************************************************************************************/ + +#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_BMP180) +int stm32_bmp180initialize(FAR const char *devpath); +#endif + #endif /* __ASSEMBLY__ */ #endif /* __CONFIGS_OLIMEX_STM32_E407_SRC_INTERNAL_H */ diff --git a/configs/olimex-stm32-e407/src/stm32_bmp180.c b/configs/olimex-stm32-e407/src/stm32_bmp180.c new file mode 100644 index 00000000000..e4bc6d55c49 --- /dev/null +++ b/configs/olimex-stm32-e407/src/stm32_bmp180.c @@ -0,0 +1,106 @@ +/************************************************************************************ + * configs/olimex-stm32-e407/src/stm32_bmp180.c + * + * Copyright (C) 2019 Acutronics Robotics. All rights reserved. + * Author: Acutronics Robotics (Juan Flores) + * Base on the implementation of: Alan Carvalho de Assis + * + * 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 NuttX 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. + * + ************************************************************************************/ + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include + +#include +#include + +#include +#include + +#include "stm32.h" +#include "stm32_i2c.h" +#include "olimex-stm32-e407.h" + +#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_BMP180) + +/************************************************************************************ + * Pre-processor Definitions + ************************************************************************************/ + +#define BMP180_I2C_PORTNO 1 /* On I2C1 */ + +/************************************************************************************ + * Public Functions + ************************************************************************************/ + +/************************************************************************************ + * Name: stm32_bmp180initialize + * + * Description: + * Initialize and register the BMP180 Pressure Sensor driver. + * + * Input parameters: + * devpath - The full path to the driver to register. E.g., "/dev/press0" + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ************************************************************************************/ + +int stm32_bmp180initialize(FAR const char *devpath) +{ + FAR struct i2c_master_s *i2c; + int ret; + + sninfo("Initializing BMP180!\n"); + + /* Initialize I2C */ + + i2c = stm32_i2cbus_initialize(BMP180_I2C_PORTNO); + + if (!i2c) + { + return -ENODEV; + } + + /* Then register the barometer sensor */ + + ret = bmp180_register(devpath, i2c); + if (ret < 0) + { + snerr("ERROR: Error registering BMP180\n"); + } + + return ret; +} + +#endif /* CONFIG_I2C && CONFIG_SENSORS_BMP180 && CONFIG_STM32_I2C1 */ diff --git a/configs/olimex-stm32-e407/src/stm32_bringup.c b/configs/olimex-stm32-e407/src/stm32_bringup.c index 0cd2851d743..2f9becd43a9 100644 --- a/configs/olimex-stm32-e407/src/stm32_bringup.c +++ b/configs/olimex-stm32-e407/src/stm32_bringup.c @@ -218,6 +218,17 @@ int stm32_bringup(void) } #endif +#ifdef CONFIG_SENSORS_BMP180 + /* Initialize the BMP180 pressure sensor. */ + + ret = stm32_bmp180initialize("/dev/press0"); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize BMP180, error %d\n", ret); + return ret; + } +#endif + UNUSED(ret); return OK; }