Viewtool STM32F107: Add support for an optional, add-on Freescale MPL115A baramoter. From Alan Carvalho de Assis
This commit is contained in:
parent
5de459efcb
commit
317dc642e4
@ -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
|
||||
=========================
|
||||
|
||||
|
@ -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
|
||||
|
101
configs/viewtool-stm32f107/src/stm32_mpl115a.c
Normal file
101
configs/viewtool-stm32f107/src/stm32_mpl115a.c
Normal file
@ -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 */
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user