diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2015-02-12 12:08:06 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2015-02-12 12:08:06 -0600 |
commit | b2cee6ced0bb4e71acc296f2867a2767247fe60c (patch) | |
tree | 43199f6d41c85aa5f91edab9ec6413e4ecc2161b /nuttx/configs | |
parent | 0ba0ab508656c4046c7e00b0c6c36ce86d061660 (diff) | |
download | px4-nuttx-b2cee6ced0bb4e71acc296f2867a2767247fe60c.tar.gz px4-nuttx-b2cee6ced0bb4e71acc296f2867a2767247fe60c.tar.bz2 px4-nuttx-b2cee6ced0bb4e71acc296f2867a2767247fe60c.zip |
Viewtool STM32F107: Add support for an optional, add-on Freescale MPL115A baramoter. From Alan Carvalho de Assis
Diffstat (limited to 'nuttx/configs')
-rw-r--r-- | nuttx/configs/viewtool-stm32f107/README.txt | 23 | ||||
-rw-r--r-- | nuttx/configs/viewtool-stm32f107/src/Makefile | 4 | ||||
-rw-r--r-- | nuttx/configs/viewtool-stm32f107/src/stm32_mpl115a.c | 101 | ||||
-rw-r--r-- | nuttx/configs/viewtool-stm32f107/src/stm32_nsh.c | 5 | ||||
-rw-r--r-- | nuttx/configs/viewtool-stm32f107/src/stm32_spi.c | 6 | ||||
-rw-r--r-- | nuttx/configs/viewtool-stm32f107/src/viewtool_stm32f107.h | 27 |
6 files changed, 165 insertions, 1 deletions
diff --git a/nuttx/configs/viewtool-stm32f107/README.txt b/nuttx/configs/viewtool-stm32f107/README.txt index 7cf4c731a..3aefe7ba4 100644 --- a/nuttx/configs/viewtool-stm32f107/README.txt +++ b/nuttx/configs/viewtool-stm32f107/README.txt @@ -28,6 +28,7 @@ Contents o USB Interface o microSD Card Interface o ViewTool DP83848 Ethernet Module + o Freescale MPL115A barometer sensor o LCD/Touchscreen Interface o Toolchains - NOTE about Windows native toolchains @@ -398,6 +399,28 @@ ViewTool DP83848 Ethernet Module (also FTP, TFTP, WGET, NFS, etc. if you also have a mass storage device). +Freescale MPL115A barometer sensor +================================== + + This board support package includes hooks that can be used to enable + testing of a Freescale MPL115A barometer sensor connected via SPI3 with + chip select on PB6, + + Here are the configuration settings that would have to be included to + enabled support for the barometer: + + System Type -> Peripherals + CONFIG_STM32_SPI3=y + + Drivers -> SPI + CONFIG_SPI=y + CONFIG_SPI_EXCHANGE=y + + Drivers -> Sensors + CONFIG_SENSORS=y + CONFIG_MPL115A=y + CONFIG_NSH_ARCHINIT=y + LCD/Touchscreen Interface ========================= diff --git a/nuttx/configs/viewtool-stm32f107/src/Makefile b/nuttx/configs/viewtool-stm32f107/src/Makefile index f5f5cf1a4..b46404cf0 100644 --- a/nuttx/configs/viewtool-stm32f107/src/Makefile +++ b/nuttx/configs/viewtool-stm32f107/src/Makefile @@ -62,6 +62,10 @@ CSRCS += stm32_usbdev.c endif endif +ifeq ($(CONFIG_MPL115A),y) +CSRCS += stm32_mpl115a.c +endif + ifeq ($(CONFIG_INPUT_ADS7843E),y) # F103 CSRCS += stm32_touchscreen.c endif diff --git a/nuttx/configs/viewtool-stm32f107/src/stm32_mpl115a.c b/nuttx/configs/viewtool-stm32f107/src/stm32_mpl115a.c new file mode 100644 index 000000000..448136118 --- /dev/null +++ b/nuttx/configs/viewtool-stm32f107/src/stm32_mpl115a.c @@ -0,0 +1,101 @@ +/************************************************************************************ + * configs/greenbone/src/stm32_mpl115a.c + * + * Copyright (C) 2015 Alan Carvalho de Assis. All rights reserved. + * Author: Alan Carvalho de Assis <acassis@gmail.com> + * + * 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 <nuttx/config.h> + +#include <errno.h> +#include <debug.h> + +#include <nuttx/spi/spi.h> +#include <nuttx/sensors/mpl115a.h> + +#include "stm32.h" +#include "stm32_spi.h" +#include "viewtool_stm32f107.h" + +#if defined(CONFIG_SPI) && defined(CONFIG_MPL115A) && defined(CONFIG_STM32_SPI3) + +/************************************************************************************ + * Pre-processor Definitions + ************************************************************************************/ + +#define MPL115A_SPI_PORTNO 3 /* On SPI3 */ + +/************************************************************************************ + * Public Functions + ************************************************************************************/ + +/************************************************************************************ + * Name: stm32_mpl115ainitialize + * + * Description: + * Initialize and register the MPL115A 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_mpl115ainitialize(FAR const char *devpath) +{ + FAR struct spi_dev_s *spi; + int ret; + + spi = up_spiinitialize(MPL115A_SPI_PORTNO); + + if (!spi) + { + return -ENODEV; + } + + /* Then register the barometer sensor */ + + ret = mpl115a_register(devpath, spi); + if (ret < 0) + { + sndbg("Error registering MPL115A\n"); + } + + return ret; +} + +#endif /* CONFIG_SPI && CONFIG_MPL115A && CONFIG_STM32_SPI3 */ diff --git a/nuttx/configs/viewtool-stm32f107/src/stm32_nsh.c b/nuttx/configs/viewtool-stm32f107/src/stm32_nsh.c index f79672f58..7f860e989 100644 --- a/nuttx/configs/viewtool-stm32f107/src/stm32_nsh.c +++ b/nuttx/configs/viewtool-stm32f107/src/stm32_nsh.c @@ -62,7 +62,6 @@ # define CONFIG_NSH_MMCSDSLOTNO VIEWTOOL_MMCSD_SLOTNO # endif #endif -#endif /**************************************************************************** * Public Functions @@ -78,6 +77,10 @@ int nsh_archinitialize(void) { +#ifdef CONFIG_MPL115A + stm32_mpl115ainitialize("/dev/press"); +#endif + #ifdef HAVE_MMCSD return stm32_sdinitialize(CONFIG_NSH_MMCSDSLOTNO); #else diff --git a/nuttx/configs/viewtool-stm32f107/src/stm32_spi.c b/nuttx/configs/viewtool-stm32f107/src/stm32_spi.c index 5ac136b3f..2e464fe5f 100644 --- a/nuttx/configs/viewtool-stm32f107/src/stm32_spi.c +++ b/nuttx/configs/viewtool-stm32f107/src/stm32_spi.c @@ -105,6 +105,12 @@ void weak_function stm32_spiinitialize(void) (void)stm32_configgpio(GPIO_LCDTP_CS); #endif + +#if defined(CONFIG_STM32_SPI3) && defined(CONFIG_MPL115A) + /* Configure the MPL115A SPI3 CS pin as an output */ + + (void)stm32_configgpio(GPIO_MPL115A_CS); +#endif } /**************************************************************************** diff --git a/nuttx/configs/viewtool-stm32f107/src/viewtool_stm32f107.h b/nuttx/configs/viewtool-stm32f107/src/viewtool_stm32f107.h index b23e71cfa..cb1ad37fd 100644 --- a/nuttx/configs/viewtool-stm32f107/src/viewtool_stm32f107.h +++ b/nuttx/configs/viewtool-stm32f107/src/viewtool_stm32f107.h @@ -276,6 +276,15 @@ #define GPIO_LCDTP_CS (GPIO_OUTPUT | GPIO_CNF_OUTPP | GPIO_MODE_50MHz | \ GPIO_OUTPUT_SET | GPIO_PORTC | GPIO_PIN4) +/* Freescale MPL115A barometer (optional add-on) + * + * This board support logic includes support for a Freescale MPL115A barometer + * using SPI3 with chip select on PB6. + */ + +#define GPIO_MPL115A_CS (GPIO_OUTPUT | GPIO_CNF_OUTPP | GPIO_MODE_50MHz | \ + GPIO_OUTPUT_SET | GPIO_PORTB | GPIO_PIN6) + /************************************************************************************ * Public Functions ************************************************************************************/ @@ -326,5 +335,23 @@ int stm32_sdinitialize(int minor); void stm32_ledinit(void); +/************************************************************************************ + * Name: stm32_mpl115ainitialize + * + * Description: + * Initialize and register the MPL115A 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_SPI) && defined(CONFIG_MPL115A) && defined(CONFIG_STM32_SPI3) +int stm32_mpl115ainitialize(FAR const char *devpath); +#endif + #endif /* __ASSEMBLY__ */ #endif /* __CONFIGS_VIEWTOOL_STM32F107_SRC_INTERNAL_H */ |