You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by je...@apache.org on 2020/05/14 06:33:20 UTC
[incubator-nuttx] 20/23: stm32: moved all remaining sensor
initialization to common board logic
This is an automated email from the ASF dual-hosted git repository.
jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 5fd9bd58375e6e0ffecaa14063ead0edc1b0a409
Author: Matias Nitsche <mn...@dc.uba.ar>
AuthorDate: Tue May 12 17:19:26 2020 -0300
stm32: moved all remaining sensor initialization to common board logic
---
.../{src/stm32_bmp180.c => include/stm32_bh1750.h} | 72 +++++++-------------
.../{src/stm32_bmp180.c => include/stm32_dhtxx.h} | 77 ++++++++--------------
.../{src/stm32_bmp180.c => include/stm32_l3gd20.h} | 74 +++++++--------------
.../stm32_bmp180.c => include/stm32_lis3dsh.h} | 74 +++++++--------------
.../stm32_bmp180.c => include/stm32_max31855.h} | 74 +++++++--------------
.../stm32_bmp180.c => include/stm32_mlx90614.h} | 72 +++++++-------------
.../stm32_bmp180.c => include/stm32_mpl115a.h} | 72 +++++++-------------
.../stm32_bmp180.c => include/stm32_xen1210.h} | 77 ++++++++--------------
boards/arm/stm32/common/src/Make.defs | 32 +++++++++
.../src/stm32_bh1750.c} | 17 ++---
boards/arm/stm32/common/src/stm32_bmp180.c | 3 -
.../src/stm32_dhtxx.c | 36 +++++-----
.../src/stm32_l3gd20.c | 27 ++++----
.../src/stm32_lis3dsh.c | 35 +++++-----
.../src/stm32_max31855.c | 24 ++++---
.../src/stm32_mlx90614.c | 21 +++---
.../src/stm32_mpl115a.c | 21 +++---
.../src/stm32_xen1210.c | 63 +++++-------------
boards/arm/stm32/olimex-stm32-p407/include/board.h | 10 +++
boards/arm/stm32/olimex-stm32-p407/src/Make.defs | 4 --
.../olimex-stm32-p407/src/olimex-stm32-p407.h | 18 -----
.../stm32/olimex-stm32-p407/src/stm32_bringup.c | 6 +-
boards/arm/stm32/stm32f429i-disco/include/board.h | 13 ++++
boards/arm/stm32/stm32f429i-disco/src/Make.defs | 4 --
.../arm/stm32/stm32f429i-disco/src/stm32_bringup.c | 6 +-
.../stm32/stm32f429i-disco/src/stm32f429i-disco.h | 5 --
boards/arm/stm32/stm32f4discovery/Kconfig | 1 +
boards/arm/stm32/stm32f4discovery/include/board.h | 21 ++++++
boards/arm/stm32/stm32f4discovery/src/Make.defs | 20 ------
.../arm/stm32/stm32f4discovery/src/stm32_bringup.c | 32 +++++++--
.../stm32/stm32f4discovery/src/stm32f4discovery.h | 25 -------
boards/arm/stm32/viewtool-stm32f107/src/Make.defs | 4 --
.../stm32/viewtool-stm32f107/src/stm32_bringup.c | 6 +-
drivers/sensors/l3gd20.c | 10 ++-
drivers/sensors/lis3dsh.c | 13 +++-
35 files changed, 424 insertions(+), 645 deletions(-)
diff --git a/boards/arm/stm32/common/src/stm32_bmp180.c b/boards/arm/stm32/common/include/stm32_bh1750.h
similarity index 65%
copy from boards/arm/stm32/common/src/stm32_bmp180.c
copy to boards/arm/stm32/common/include/stm32_bh1750.h
index 1be621c..2f7e723 100644
--- a/boards/arm/stm32/common/src/stm32_bmp180.c
+++ b/boards/arm/stm32/common/include/stm32_bh1750.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * boards/arm/stm32/common/src/stm32_bmp180.c
+ * /home/v01d/coding/nuttx_latest/nuttx/boards/arm/stm32/common/include/stm32_bh1750.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -18,55 +18,51 @@
*
****************************************************************************/
+#ifndef __STM32_BH1750_H
+#define __STM32_BH1750_H
+
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
-#include <nuttx/arch.h>
-#include <nuttx/sensors/bmp180.h>
-#include <nuttx/i2c/i2c_master.h>
-#include <stdio.h>
-#include "stm32_i2c.h"
-
-#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_BMP180)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
- * Private Types
- ****************************************************************************/
-
-/****************************************************************************
- * Private Function Prototypes
- ****************************************************************************/
-
-/****************************************************************************
- * Private Data
+ * Public Types
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
/****************************************************************************
- * Private Functions
+ * Inline Functions
****************************************************************************/
/****************************************************************************
- * Public Functions
+ * Public Function Prototypes
****************************************************************************/
/****************************************************************************
- * Name: board_bmp180_initialize
+ * Name: board_bh1750_initialize
*
* Description:
- * Initialize and register the BMP180 Pressure Sensor driver.
+ * Initialize and register the MPL115A Pressure Sensor driver.
*
* Input Parameters:
- * devno - The device number, used to build the device path as /dev/pressN
+ * devno - The device number, used to build the device path as /dev/lightN
* busno - The I2C bus number
*
* Returned Value:
@@ -74,33 +70,11 @@
*
****************************************************************************/
-int board_bmp180_initialize(int devno, int busno)
-{
- FAR struct i2c_master_s *i2c;
- char devpath[12];
- int ret;
-
- sninfo("Initializing BMP180!\n");
-
- /* Initialize I2C */
-
- i2c = stm32_i2cbus_initialize(busno);
+int board_bh1750_initialize(int devno, int busno);
- if (!i2c)
- {
- return -ENODEV;
- }
-
- /* Then register the barometer sensor */
-
- snprintf(devpath, 12, "/dev/press%d", devno);
- ret = bmp180_register(devpath, i2c);
- if (ret < 0)
- {
- snerr("ERROR: Error registering BM180\n");
- }
-
- return ret;
+#undef EXTERN
+#ifdef __cplusplus
}
-
#endif
+
+#endif // __STM32_BH1750_H
diff --git a/boards/arm/stm32/common/src/stm32_bmp180.c b/boards/arm/stm32/common/include/stm32_dhtxx.h
similarity index 63%
copy from boards/arm/stm32/common/src/stm32_bmp180.c
copy to boards/arm/stm32/common/include/stm32_dhtxx.h
index 1be621c..123d6e8 100644
--- a/boards/arm/stm32/common/src/stm32_bmp180.c
+++ b/boards/arm/stm32/common/include/stm32_dhtxx.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * boards/arm/stm32/common/src/stm32_bmp180.c
+ * /home/v01d/coding/nuttx_latest/nuttx/boards/arm/stm32/common/include/stm32_dhtxx.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -18,89 +18,64 @@
*
****************************************************************************/
+#ifndef __STM32_DHTXX_H
+#define __STM32_DHTXX_H
+
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
-#include <nuttx/arch.h>
-#include <nuttx/sensors/bmp180.h>
-#include <nuttx/i2c/i2c_master.h>
-#include <stdio.h>
-#include "stm32_i2c.h"
-
-#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_BMP180)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
- * Private Types
- ****************************************************************************/
-
-/****************************************************************************
- * Private Function Prototypes
- ****************************************************************************/
-
-/****************************************************************************
- * Private Data
+ * Public Types
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
/****************************************************************************
- * Private Functions
+ * Inline Functions
****************************************************************************/
/****************************************************************************
- * Public Functions
+ * Public Function Prototypes
****************************************************************************/
/****************************************************************************
- * Name: board_bmp180_initialize
+ * Name: board_dhtxx_initialize
*
* Description:
- * Initialize and register the BMP180 Pressure Sensor driver.
+ * This function is called by application-specific, setup logic to
+ * configure the DHTxx sensor.
*
* Input Parameters:
- * devno - The device number, used to build the device path as /dev/pressN
- * busno - The I2C bus number
+ * devno - The device number, used to build the device path as /dev/humN.
*
* Returned Value:
- * Zero (OK) on success; a negated errno value on failure.
+ * Zero (OK) returned on success;
+ * a negated errno value is returned on failure.
*
****************************************************************************/
-int board_bmp180_initialize(int devno, int busno)
-{
- FAR struct i2c_master_s *i2c;
- char devpath[12];
- int ret;
-
- sninfo("Initializing BMP180!\n");
-
- /* Initialize I2C */
-
- i2c = stm32_i2cbus_initialize(busno);
+int board_dhtxx_initialize(int devno);
- if (!i2c)
- {
- return -ENODEV;
- }
-
- /* Then register the barometer sensor */
-
- snprintf(devpath, 12, "/dev/press%d", devno);
- ret = bmp180_register(devpath, i2c);
- if (ret < 0)
- {
- snerr("ERROR: Error registering BM180\n");
- }
-
- return ret;
+#undef EXTERN
+#ifdef __cplusplus
}
-
#endif
+
+#endif // __STM32_DHTXX_H
diff --git a/boards/arm/stm32/common/src/stm32_bmp180.c b/boards/arm/stm32/common/include/stm32_l3gd20.h
similarity index 64%
copy from boards/arm/stm32/common/src/stm32_bmp180.c
copy to boards/arm/stm32/common/include/stm32_l3gd20.h
index 1be621c..9abecb4 100644
--- a/boards/arm/stm32/common/src/stm32_bmp180.c
+++ b/boards/arm/stm32/common/include/stm32_l3gd20.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * boards/arm/stm32/common/src/stm32_bmp180.c
+ * /home/v01d/coding/nuttx_latest/nuttx/boards/arm/stm32/common/include/stm32_l3gd20.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -18,89 +18,63 @@
*
****************************************************************************/
+#ifndef __STM32_L3GD20_H
+#define __STM32_L3GD20_H
+
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
-#include <nuttx/arch.h>
-#include <nuttx/sensors/bmp180.h>
-#include <nuttx/i2c/i2c_master.h>
-#include <stdio.h>
-#include "stm32_i2c.h"
-
-#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_BMP180)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
- * Private Types
- ****************************************************************************/
-
-/****************************************************************************
- * Private Function Prototypes
- ****************************************************************************/
-
-/****************************************************************************
- * Private Data
+ * Public Types
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
/****************************************************************************
- * Private Functions
+ * Inline Functions
****************************************************************************/
/****************************************************************************
- * Public Functions
+ * Public Function Prototypes
****************************************************************************/
/****************************************************************************
- * Name: board_bmp180_initialize
+ * Name: board_l3gd20_initialize()
*
* Description:
- * Initialize and register the BMP180 Pressure Sensor driver.
+ * Initialize and register the L3GD20 3 axis gyroscope sensor driver.
*
* Input Parameters:
- * devno - The device number, used to build the device path as /dev/pressN
- * busno - The I2C bus number
+ * devno - The device number, used to build the device path as /dev/gyroN
+ * busno - The SPI bus number
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
-int board_bmp180_initialize(int devno, int busno)
-{
- FAR struct i2c_master_s *i2c;
- char devpath[12];
- int ret;
-
- sninfo("Initializing BMP180!\n");
-
- /* Initialize I2C */
-
- i2c = stm32_i2cbus_initialize(busno);
+int board_l3gd20_initialize(int devno, int busno);
- if (!i2c)
- {
- return -ENODEV;
- }
-
- /* Then register the barometer sensor */
-
- snprintf(devpath, 12, "/dev/press%d", devno);
- ret = bmp180_register(devpath, i2c);
- if (ret < 0)
- {
- snerr("ERROR: Error registering BM180\n");
- }
-
- return ret;
+#undef EXTERN
+#ifdef __cplusplus
}
-
#endif
+
+#endif // __STM32_L3GD20_H
diff --git a/boards/arm/stm32/common/src/stm32_bmp180.c b/boards/arm/stm32/common/include/stm32_lis3dsh.h
similarity index 64%
copy from boards/arm/stm32/common/src/stm32_bmp180.c
copy to boards/arm/stm32/common/include/stm32_lis3dsh.h
index 1be621c..e43b33c 100644
--- a/boards/arm/stm32/common/src/stm32_bmp180.c
+++ b/boards/arm/stm32/common/include/stm32_lis3dsh.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * boards/arm/stm32/common/src/stm32_bmp180.c
+ * boards/arm/stm32/common/include/stm32_lis3dsh.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -18,89 +18,63 @@
*
****************************************************************************/
+#ifndef __STM32_LIS3DSH_H
+#define __STM32_LIS3DSH_H
+
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
-#include <nuttx/arch.h>
-#include <nuttx/sensors/bmp180.h>
-#include <nuttx/i2c/i2c_master.h>
-#include <stdio.h>
-#include "stm32_i2c.h"
-
-#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_BMP180)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
- * Private Types
- ****************************************************************************/
-
-/****************************************************************************
- * Private Function Prototypes
- ****************************************************************************/
-
-/****************************************************************************
- * Private Data
+ * Public Types
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
/****************************************************************************
- * Private Functions
+ * Inline Functions
****************************************************************************/
/****************************************************************************
- * Public Functions
+ * Public Function Prototypes
****************************************************************************/
/****************************************************************************
- * Name: board_bmp180_initialize
+ * Name: board_lis3dsh_initialize
*
* Description:
- * Initialize and register the BMP180 Pressure Sensor driver.
+ * Initialize and register the LIS3DSH 3-axis accelerometer.
*
* Input Parameters:
- * devno - The device number, used to build the device path as /dev/pressN
- * busno - The I2C bus number
+ * devno - The device number, used to build the device path as /dev/accN
+ * busno - The SPI bus number
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
-int board_bmp180_initialize(int devno, int busno)
-{
- FAR struct i2c_master_s *i2c;
- char devpath[12];
- int ret;
-
- sninfo("Initializing BMP180!\n");
-
- /* Initialize I2C */
-
- i2c = stm32_i2cbus_initialize(busno);
+int board_lis3dsh_initialize(int devno, int busno);
- if (!i2c)
- {
- return -ENODEV;
- }
-
- /* Then register the barometer sensor */
-
- snprintf(devpath, 12, "/dev/press%d", devno);
- ret = bmp180_register(devpath, i2c);
- if (ret < 0)
- {
- snerr("ERROR: Error registering BM180\n");
- }
-
- return ret;
+#undef EXTERN
+#ifdef __cplusplus
}
-
#endif
+
+#endif // __STM32_LIS3DSH_H
diff --git a/boards/arm/stm32/common/src/stm32_bmp180.c b/boards/arm/stm32/common/include/stm32_max31855.h
similarity index 64%
copy from boards/arm/stm32/common/src/stm32_bmp180.c
copy to boards/arm/stm32/common/include/stm32_max31855.h
index 1be621c..922c352 100644
--- a/boards/arm/stm32/common/src/stm32_bmp180.c
+++ b/boards/arm/stm32/common/include/stm32_max31855.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * boards/arm/stm32/common/src/stm32_bmp180.c
+ * boards/arm/stm32/common/include/stm32_max31855.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -18,89 +18,63 @@
*
****************************************************************************/
+#ifndef __STM32_MAX31855_H
+#define __STM32_MAX31855_H
+
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
-#include <nuttx/arch.h>
-#include <nuttx/sensors/bmp180.h>
-#include <nuttx/i2c/i2c_master.h>
-#include <stdio.h>
-#include "stm32_i2c.h"
-
-#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_BMP180)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
- * Private Types
- ****************************************************************************/
-
-/****************************************************************************
- * Private Function Prototypes
- ****************************************************************************/
-
-/****************************************************************************
- * Private Data
+ * Public Types
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
/****************************************************************************
- * Private Functions
+ * Inline Functions
****************************************************************************/
/****************************************************************************
- * Public Functions
+ * Public Function Prototypes
****************************************************************************/
/****************************************************************************
- * Name: board_bmp180_initialize
+ * Name: board_max31855_initialize
*
* Description:
- * Initialize and register the BMP180 Pressure Sensor driver.
+ * Initialize and register the MAX31855 Temperature Sensor driver.
*
* Input Parameters:
- * devno - The device number, used to build the device path as /dev/pressN
- * busno - The I2C bus number
+ * devno - The device number, used to build the device path as /dev/tempN
+ * busno - The SPI bus number
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
-int board_bmp180_initialize(int devno, int busno)
-{
- FAR struct i2c_master_s *i2c;
- char devpath[12];
- int ret;
-
- sninfo("Initializing BMP180!\n");
-
- /* Initialize I2C */
-
- i2c = stm32_i2cbus_initialize(busno);
+int board_max31855_initialize(int devno, int busno);
- if (!i2c)
- {
- return -ENODEV;
- }
-
- /* Then register the barometer sensor */
-
- snprintf(devpath, 12, "/dev/press%d", devno);
- ret = bmp180_register(devpath, i2c);
- if (ret < 0)
- {
- snerr("ERROR: Error registering BM180\n");
- }
-
- return ret;
+#undef EXTERN
+#ifdef __cplusplus
}
-
#endif
+
+#endif // __STM32_MAX31855_H
diff --git a/boards/arm/stm32/common/src/stm32_bmp180.c b/boards/arm/stm32/common/include/stm32_mlx90614.h
similarity index 65%
copy from boards/arm/stm32/common/src/stm32_bmp180.c
copy to boards/arm/stm32/common/include/stm32_mlx90614.h
index 1be621c..4191792 100644
--- a/boards/arm/stm32/common/src/stm32_bmp180.c
+++ b/boards/arm/stm32/common/include/stm32_mlx90614.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * boards/arm/stm32/common/src/stm32_bmp180.c
+ * boards/arm/stm32/common/include/stm32_mlx90614.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -18,55 +18,51 @@
*
****************************************************************************/
+#ifndef __STM32_MLX90614_H
+#define __STM32_MLX90614_H
+
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
-#include <nuttx/arch.h>
-#include <nuttx/sensors/bmp180.h>
-#include <nuttx/i2c/i2c_master.h>
-#include <stdio.h>
-#include "stm32_i2c.h"
-
-#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_BMP180)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
- * Private Types
- ****************************************************************************/
-
-/****************************************************************************
- * Private Function Prototypes
- ****************************************************************************/
-
-/****************************************************************************
- * Private Data
+ * Public Types
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
/****************************************************************************
- * Private Functions
+ * Inline Functions
****************************************************************************/
/****************************************************************************
- * Public Functions
+ * Public Function Prototypes
****************************************************************************/
/****************************************************************************
- * Name: board_bmp180_initialize
+ * Name: board_mlx90614_initialize
*
* Description:
- * Initialize and register the BMP180 Pressure Sensor driver.
+ * Initialize and register the MLX90614 Infrared Thermometer.
*
* Input Parameters:
- * devno - The device number, used to build the device path as /dev/pressN
+ * devno - The device number, used to build the device path as /dev/thermN
* busno - The I2C bus number
*
* Returned Value:
@@ -74,33 +70,11 @@
*
****************************************************************************/
-int board_bmp180_initialize(int devno, int busno)
-{
- FAR struct i2c_master_s *i2c;
- char devpath[12];
- int ret;
-
- sninfo("Initializing BMP180!\n");
-
- /* Initialize I2C */
-
- i2c = stm32_i2cbus_initialize(busno);
+int board_mlx90614_initialize(int devno, int busno);
- if (!i2c)
- {
- return -ENODEV;
- }
-
- /* Then register the barometer sensor */
-
- snprintf(devpath, 12, "/dev/press%d", devno);
- ret = bmp180_register(devpath, i2c);
- if (ret < 0)
- {
- snerr("ERROR: Error registering BM180\n");
- }
-
- return ret;
+#undef EXTERN
+#ifdef __cplusplus
}
-
#endif
+
+#endif // __STM32_MLX90614_H
diff --git a/boards/arm/stm32/common/src/stm32_bmp180.c b/boards/arm/stm32/common/include/stm32_mpl115a.h
similarity index 65%
copy from boards/arm/stm32/common/src/stm32_bmp180.c
copy to boards/arm/stm32/common/include/stm32_mpl115a.h
index 1be621c..d8ae97d 100644
--- a/boards/arm/stm32/common/src/stm32_bmp180.c
+++ b/boards/arm/stm32/common/include/stm32_mpl115a.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * boards/arm/stm32/common/src/stm32_bmp180.c
+ * boards/arm/stm32/common/include/stm32_mpl115a.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -18,89 +18,63 @@
*
****************************************************************************/
+#ifndef __STM32_MPL115A_H
+#define __STM32_MPL115A_H
+
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
-#include <nuttx/arch.h>
-#include <nuttx/sensors/bmp180.h>
-#include <nuttx/i2c/i2c_master.h>
-#include <stdio.h>
-#include "stm32_i2c.h"
-
-#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_BMP180)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
- * Private Types
- ****************************************************************************/
-
-/****************************************************************************
- * Private Function Prototypes
- ****************************************************************************/
-
-/****************************************************************************
- * Private Data
+ * Public Types
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
/****************************************************************************
- * Private Functions
+ * Inline Functions
****************************************************************************/
/****************************************************************************
- * Public Functions
+ * Public Function Prototypes
****************************************************************************/
/****************************************************************************
- * Name: board_bmp180_initialize
+ * Name: board_mpl115a_initialize
*
* Description:
- * Initialize and register the BMP180 Pressure Sensor driver.
+ * Initialize and register the MPL115A Pressure Sensor driver.
*
* Input Parameters:
* devno - The device number, used to build the device path as /dev/pressN
- * busno - The I2C bus number
+ * busno - The SPI bus number
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
-int board_bmp180_initialize(int devno, int busno)
-{
- FAR struct i2c_master_s *i2c;
- char devpath[12];
- int ret;
-
- sninfo("Initializing BMP180!\n");
-
- /* Initialize I2C */
-
- i2c = stm32_i2cbus_initialize(busno);
+int board_mpl115a_initialize(int devno, int busno);
- if (!i2c)
- {
- return -ENODEV;
- }
-
- /* Then register the barometer sensor */
-
- snprintf(devpath, 12, "/dev/press%d", devno);
- ret = bmp180_register(devpath, i2c);
- if (ret < 0)
- {
- snerr("ERROR: Error registering BM180\n");
- }
-
- return ret;
+#undef EXTERN
+#ifdef __cplusplus
}
-
#endif
+
+#endif // __STM32_MPL115A_H
diff --git a/boards/arm/stm32/common/src/stm32_bmp180.c b/boards/arm/stm32/common/include/stm32_xen1210.h
similarity index 63%
copy from boards/arm/stm32/common/src/stm32_bmp180.c
copy to boards/arm/stm32/common/include/stm32_xen1210.h
index 1be621c..f127901 100644
--- a/boards/arm/stm32/common/src/stm32_bmp180.c
+++ b/boards/arm/stm32/common/include/stm32_xen1210.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * boards/arm/stm32/common/src/stm32_bmp180.c
+ * boards/arm/stm32/common/include/stm32_xen1210.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -18,89 +18,64 @@
*
****************************************************************************/
+#ifndef __STM32_XEN1210_H
+#define __STM32_XEN1210_H
+
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
-#include <nuttx/arch.h>
-#include <nuttx/sensors/bmp180.h>
-#include <nuttx/i2c/i2c_master.h>
-#include <stdio.h>
-#include "stm32_i2c.h"
-
-#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_BMP180)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
- * Private Types
- ****************************************************************************/
-
-/****************************************************************************
- * Private Function Prototypes
- ****************************************************************************/
-
-/****************************************************************************
- * Private Data
+ * Public Types
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
/****************************************************************************
- * Private Functions
+ * Inline Functions
****************************************************************************/
/****************************************************************************
- * Public Functions
+ * Public Function Prototypes
****************************************************************************/
/****************************************************************************
- * Name: board_bmp180_initialize
+ * Name: xen1210_archinitialize
*
* Description:
- * Initialize and register the BMP180 Pressure Sensor driver.
+ * Initialize the XEN1210 device driver
*
* Input Parameters:
- * devno - The device number, used to build the device path as /dev/pressN
- * busno - The I2C bus number
+ * devno - The device number, used to build the device path as /dev/accelN
+ * busno - The SPI bus number
*
* Returned Value:
- * Zero (OK) on success; a negated errno value on failure.
+ * Zero is returned on success. Otherwise, a negated errno value is
+ * returned to indicate the nature of the failure.
*
****************************************************************************/
-int board_bmp180_initialize(int devno, int busno)
-{
- FAR struct i2c_master_s *i2c;
- char devpath[12];
- int ret;
-
- sninfo("Initializing BMP180!\n");
-
- /* Initialize I2C */
-
- i2c = stm32_i2cbus_initialize(busno);
+int board_xen1210_initialize(int devno, int busno);
- if (!i2c)
- {
- return -ENODEV;
- }
-
- /* Then register the barometer sensor */
-
- snprintf(devpath, 12, "/dev/press%d", devno);
- ret = bmp180_register(devpath, i2c);
- if (ret < 0)
- {
- snerr("ERROR: Error registering BM180\n");
- }
-
- return ret;
+#undef EXTERN
+#ifdef __cplusplus
}
-
#endif
+
+#endif // __STM32_XEN1210_H
diff --git a/boards/arm/stm32/common/src/Make.defs b/boards/arm/stm32/common/src/Make.defs
index e195cc2..a309b06 100644
--- a/boards/arm/stm32/common/src/Make.defs
+++ b/boards/arm/stm32/common/src/Make.defs
@@ -74,6 +74,38 @@ ifeq ($(CONFIG_SENSORS_INA219),y)
CSRCS += stm32_ina219.c
endif
+ifeq ($(CONFIG_SENSORS_L3GD20),y)
+ CSRCS += stm32_l3gd20.c
+endif
+
+ifeq ($(CONFIG_SENSORS_MPL115A),y)
+ CSRCS += stm32_mpl115a.c
+endif
+
+ifeq ($(CONFIG_SENSORS_DHTXX),y)
+ CSRCS += stm32_dhtxx.c
+endif
+
+ifeq ($(CONFIG_SENSORS_XEN1210),y)
+ CSRCS += stm32_xen1210.c
+endif
+
+ifeq ($(CONFIG_SENSORS_BH1750FVI),y)
+ CSRCS += stm32_bh1750.c
+endif
+
+ifeq ($(CONFIG_SENSORS_MLX90614),y)
+ CSRCS += stm32_mlx90614.c
+endif
+
+ifeq ($(CONFIG_SENSORS_MAX31855),y)
+ CSRCS += stm32_max31855.c
+endif
+
+ifeq ($(CONFIG_LIS3DSH),y)
+ CSRCS += stm32_lis3dsh.c
+endif
+
DEPPATH += --dep-path src
VPATH += :src
CFLAGS += $(shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src)
diff --git a/boards/arm/stm32/stm32f4discovery/src/stm32_bh1750fvi.c b/boards/arm/stm32/common/src/stm32_bh1750.c
similarity index 87%
rename from boards/arm/stm32/stm32f4discovery/src/stm32_bh1750fvi.c
rename to boards/arm/stm32/common/src/stm32_bh1750.c
index ab4ee0e..16890c8 100644
--- a/boards/arm/stm32/stm32f4discovery/src/stm32_bh1750fvi.c
+++ b/boards/arm/stm32/common/src/stm32_bh1750.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * boards/arm/stm32/stm32f4discovery/src/stm32_bh1750fvi.c
+ * boards/arm/stm32/common/src/stm32_bh1750fvi.c
*
* Copyright (C) 2016 Alan Carvalho de Assis. All rights reserved.
* Author: Alan Carvalho de Assis <ac...@gmail.com>
@@ -41,22 +41,19 @@
#include <errno.h>
#include <debug.h>
+#include <stdio.h>
#include <nuttx/spi/spi.h>
+#include <arch/board/board.h>
#include <nuttx/sensors/bh1750fvi.h>
#include "stm32.h"
#include "stm32_i2c.h"
-#include "stm32f4discovery.h"
-
-#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_BH1750FVI)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
-#define BH1750FVI_I2C_PORTNO 1 /* On I2C1 */
-
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -68,14 +65,15 @@
* Initialize and register the MPL115A Pressure Sensor driver.
*
* Input Parameters:
- * devpath - The full path to the driver to register. E.g., "/dev/light0"
+ * devno - The device number, used to build the device path as /dev/lightN
+ * busno - The I2C bus number
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
-int stm32_bh1750initialize(FAR const char *devpath)
+int board_bh1750_initialize(int devno, int busno)
{
FAR struct i2c_master_s *i2c;
int ret;
@@ -84,7 +82,7 @@ int stm32_bh1750initialize(FAR const char *devpath)
/* Initialize I2C */
- i2c = stm32_i2cbus_initialize(BH1750FVI_I2C_PORTNO);
+ i2c = stm32_i2cbus_initialize(busno);
if (!i2c)
{
@@ -102,4 +100,3 @@ int stm32_bh1750initialize(FAR const char *devpath)
return ret;
}
-#endif /* CONFIG_I2C && CONFIG_SENSORS_BH1750FVI && CONFIG_STM32_I2C1 */
diff --git a/boards/arm/stm32/common/src/stm32_bmp180.c b/boards/arm/stm32/common/src/stm32_bmp180.c
index 1be621c..84b625c 100644
--- a/boards/arm/stm32/common/src/stm32_bmp180.c
+++ b/boards/arm/stm32/common/src/stm32_bmp180.c
@@ -29,8 +29,6 @@
#include <stdio.h>
#include "stm32_i2c.h"
-#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_BMP180)
-
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@@ -103,4 +101,3 @@ int board_bmp180_initialize(int devno, int busno)
return ret;
}
-#endif
diff --git a/boards/arm/stm32/olimex-stm32-p407/src/stm32_dhtxx.c b/boards/arm/stm32/common/src/stm32_dhtxx.c
similarity index 86%
rename from boards/arm/stm32/olimex-stm32-p407/src/stm32_dhtxx.c
rename to boards/arm/stm32/common/src/stm32_dhtxx.c
index b0a98c6..680198c 100644
--- a/boards/arm/stm32/olimex-stm32-p407/src/stm32_dhtxx.c
+++ b/boards/arm/stm32/common/src/stm32_dhtxx.c
@@ -43,24 +43,19 @@
#include <unistd.h>
#include <errno.h>
#include <debug.h>
+#include <stdio.h>
#include <nuttx/board.h>
#include <nuttx/sensors/dhtxx.h>
+#include <arch/board/board.h>
#include "stm32.h"
#include "stm32_freerun.h"
-#include "olimex-stm32-p407.h"
-
-#if defined(CONFIG_SENSORS_DHTXX)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
-/* Use TIM1 as free running timer for the DHTXX sensor. */
-
-#define DHTXX_FREE_TIMER 1
-
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
@@ -94,22 +89,22 @@ static void dhtxx_config_data_pin(FAR struct dhtxx_config_s *state, bool mode)
{
if (mode)
{
- stm32_configgpio(GPIO_DHTXX_PIN_INPUT);
+ stm32_configgpio(BOARD_DHTXX_GPIO_INPUT);
}
else
{
- stm32_configgpio(GPIO_DHTXX_PIN_OUTPUT);
+ stm32_configgpio(BOARD_DHTXX_GPIO_OUTPUT);
}
}
static void dhtxx_set_data_pin(FAR struct dhtxx_config_s *state, bool value)
{
- stm32_gpiowrite(GPIO_DHTXX_PIN_OUTPUT, value);
+ stm32_gpiowrite(BOARD_DHTXX_GPIO_OUTPUT, value);
}
static bool dhtxx_read_data_pin(FAR struct dhtxx_config_s *state)
{
- return stm32_gpioread(GPIO_DHTXX_PIN_INPUT);
+ return stm32_gpioread(BOARD_DHTXX_GPIO_INPUT);
}
static int64_t dhtxx_get_clock(FAR struct dhtxx_config_s *state)
@@ -128,15 +123,14 @@ static int64_t dhtxx_get_clock(FAR struct dhtxx_config_s *state)
****************************************************************************/
/****************************************************************************
- * Name: stm32_dhtxx_initialize
+ * Name: board_dhtxx_initialize
*
* Description:
* This function is called by application-specific, setup logic to
- * configure the DHTxx sensor. This function will register the driver
- * with the name passed at *devpath.
+ * configure the DHTxx sensor.
*
* Input Parameters:
- * devpath - The device name to register.
+ * devno - The device number, used to build the device path as /dev/humN.
*
* Returned Value:
* Zero (OK) returned on success;
@@ -144,23 +138,25 @@ static int64_t dhtxx_get_clock(FAR struct dhtxx_config_s *state)
*
****************************************************************************/
-int stm32_dhtxx_initialize(FAR const char *devpath)
+int board_dhtxx_initialize(int devno)
{
int ret;
+ char devpath[12];
- stm32_configgpio(GPIO_DHTXX_PIN);
+ stm32_configgpio(BOARD_DHTXX_GPIO_OUTPUT);
- stm32_gpiowrite(GPIO_DHTXX_PIN, false);
+ stm32_gpiowrite(BOARD_DHTXX_GPIO_OUTPUT, false);
/* Initialize the free-running timer with 1uS resolution */
- ret = stm32_freerun_initialize(&g_freerun, DHTXX_FREE_TIMER, 1);
+ ret = stm32_freerun_initialize(&g_freerun, BOARD_DHTXX_FRTIMER, 1);
if (ret < 0)
{
snerr("Failed to initialize the free running timer! Err = %d\n", ret);
return -ENODEV;
}
+ snprintf(devpath, 12, "/dev/hum%d", devno);
ret = dhtxx_register(devpath, &g_dhtxx_config);
if (ret < 0)
{
@@ -169,5 +165,3 @@ int stm32_dhtxx_initialize(FAR const char *devpath)
return ret;
}
-
-#endif /* CONFIG_SENSORS_DHTXX */
diff --git a/boards/arm/stm32/stm32f429i-disco/src/stm32_l3gd20.c b/boards/arm/stm32/common/src/stm32_l3gd20.c
similarity index 88%
rename from boards/arm/stm32/stm32f429i-disco/src/stm32_l3gd20.c
rename to boards/arm/stm32/common/src/stm32_l3gd20.c
index f1f50d9..0bbc15e 100644
--- a/boards/arm/stm32/stm32f429i-disco/src/stm32_l3gd20.c
+++ b/boards/arm/stm32/common/src/stm32_l3gd20.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * boards/arm/stm32/stm32f429i-disco/src/stm32_l3gd20.c
+ * boards/arm/stm32/common/src/stm32_l3gd20.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Mateusz Szafoni <ra...@railab.me>
@@ -41,20 +41,19 @@
#include <errno.h>
#include <debug.h>
+#include <stdio.h>
#include <nuttx/spi/spi.h>
#include <nuttx/sensors/l3gd20.h>
+#include <arch/board/board.h>
#include "stm32.h"
#include "stm32_spi.h"
-#include "stm32f429i-disco.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
-#if defined(CONFIG_SPI) & defined(CONFIG_SENSORS_L3GD20)
-
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
@@ -70,7 +69,7 @@ static int l3gd20_attach(FAR struct l3gd20_config_s * cfg, xcpt_t irq);
static struct l3gd20_config_s g_l3gd20_config =
{
.attach = l3gd20_attach,
- .irq = L3GD20_IRQ,
+ .irq = BOARD_L3GD20_IRQ,
.spi_devid = SPIDEV_ACCELEROMETER(0)
};
@@ -87,7 +86,8 @@ static struct l3gd20_config_s g_l3gd20_config =
static int l3gd20_attach(FAR struct l3gd20_config_s *cfg, xcpt_t irq)
{
- return stm32_gpiosetevent(GPIO_L3GD20_DREADY, true, false, true, irq, NULL);
+ return stm32_gpiosetevent(BOARD_L3GD20_GPIO_DREADY, true, false,
+ true, irq, NULL);
}
/****************************************************************************
@@ -95,31 +95,33 @@ static int l3gd20_attach(FAR struct l3gd20_config_s *cfg, xcpt_t irq)
****************************************************************************/
/****************************************************************************
- * Name: stm32_l3gd20initialize()
+ * Name: board_l3gd20_initialize()
*
* Description:
* Initialize and register the L3GD20 3 axis gyroscope sensor driver.
*
* Input Parameters:
- * devpath - The full path to the driver to register. E.g., "/dev/gyro0"
+ * devno - The device number, used to build the device path as /dev/gyroN
+ * busno - The SPI bus number
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
-int stm32_l3gd20initialize(FAR const char *devpath)
+int board_l3gd20_initialize(int devno, int busno)
{
int ret = 0;
struct spi_dev_s *spi;
+ char devpath[12];
/* Configure DREADY IRQ input */
- stm32_configgpio(GPIO_L3GD20_DREADY);
+ stm32_configgpio(BOARD_L3GD20_GPIO_DREADY);
/* Initialize SPI */
- spi = stm32_spi5initialize();
+ spi = stm32_spibus_initialize(busno);
if (!spi)
{
@@ -129,6 +131,7 @@ int stm32_l3gd20initialize(FAR const char *devpath)
/* Then register the gyro */
+ snprintf(devpath, 12, "/dev/gyro%d", devno);
ret = l3gd20_register(devpath, spi, &g_l3gd20_config);
if (ret != OK)
{
@@ -138,5 +141,3 @@ int stm32_l3gd20initialize(FAR const char *devpath)
errout:
return ret;
}
-
-#endif /* CONFIG_SPI && CONFIG_SENSORS_L3GD20 */
diff --git a/boards/arm/stm32/stm32f4discovery/src/stm32_lis3dsh.c b/boards/arm/stm32/common/src/stm32_lis3dsh.c
similarity index 81%
rename from boards/arm/stm32/stm32f4discovery/src/stm32_lis3dsh.c
rename to boards/arm/stm32/common/src/stm32_lis3dsh.c
index c4e2404..0c640a4 100644
--- a/boards/arm/stm32/stm32f4discovery/src/stm32_lis3dsh.c
+++ b/boards/arm/stm32/common/src/stm32_lis3dsh.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * boards/arm/stm32/stm32f4discovery/src/stm32_lis3dsh.c
+ * boards/arm/stm32/common/src/stm32_lis3dsh.c
*
* Copyright (C) 2017 Florian Olbrich. All rights reserved.
* Author: Florian Olbrich <fl...@posteo.de>
@@ -41,22 +41,18 @@
#include <errno.h>
#include <debug.h>
+#include <stdio.h>
#include <nuttx/spi/spi.h>
#include <nuttx/sensors/lis3dsh.h>
+#include <arch/board/board.h>
#include "stm32.h"
-#include "stm32f4discovery.h"
-
-#if defined(CONFIG_STM32F4DISCO_LIS3DSH) && defined(CONFIG_LIS3DSH)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
-#define GPIO_STM32F4DISCO_LIS3DSH_EXT0 \
- (GPIO_INPUT|GPIO_FLOAT|GPIO_AF0|GPIO_SPEED_50MHz|GPIO_PORTE|GPIO_PIN0)
-
/****************************************************************************
* Private Functions
****************************************************************************/
@@ -78,14 +74,11 @@
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
-int attach_disc_lis3dsh(FAR struct lis3dsh_config_s *config, xcpt_t interrupt_handler)
+int attach_disc_lis3dsh(FAR struct lis3dsh_config_s *config,
+ xcpt_t interrupt_handler)
{
- return stm32_gpiosetevent(GPIO_STM32F4DISCO_LIS3DSH_EXT0,
- true,
- false,
- false,
- interrupt_handler,
- NULL );
+ return stm32_gpiosetevent(BOARD_LIS3DSH_GPIO_EXT0, true, false, false,
+ interrupt_handler, NULL);
}
/****************************************************************************
@@ -93,29 +86,31 @@ int attach_disc_lis3dsh(FAR struct lis3dsh_config_s *config, xcpt_t interrupt_ha
****************************************************************************/
/****************************************************************************
- * Name: stm32_lis3dshinitialize
+ * Name: board_lis3dsh_initialize
*
* Description:
* Initialize and register the LIS3DSH 3-axis accelerometer.
*
* Input Parameters:
- * devpath - The full path to the driver to register. E.g., "/dev/acc0"
+ * devno - The device number, used to build the device path as /dev/accN
+ * busno - The SPI bus number
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
-int stm32_lis3dshinitialize(FAR const char *devpath)
+int board_lis3dsh_initialize(int devno, int busno)
{
static struct lis3dsh_config_s acc0_config;
+ char devpath[12];
struct spi_dev_s *spi;
int ret;
sninfo("Initializing LIS3DSH\n");
- acc0_config.irq=22;
- acc0_config.spi_devid=0;
+ acc0_config.irq = 22;
+ acc0_config.spi_devid = 0;
acc0_config.attach = &attach_disc_lis3dsh;
spi = stm32_spibus_initialize(1);
@@ -126,10 +121,10 @@ int stm32_lis3dshinitialize(FAR const char *devpath)
}
else
{
+ snprintf(devpath, 12, "/dev/acc%d", devno);
ret = lis3dsh_register(devpath, spi, &acc0_config);
}
return ret;
}
-#endif /* CONFIG_STM32F4DISCO_LIS3DSH && CONFIG_LIS3DSH */
diff --git a/boards/arm/stm32/stm32f4discovery/src/stm32_max31855.c b/boards/arm/stm32/common/src/stm32_max31855.c
similarity index 81%
rename from boards/arm/stm32/stm32f4discovery/src/stm32_max31855.c
rename to boards/arm/stm32/common/src/stm32_max31855.c
index 913ad5f..b6e6eea 100644
--- a/boards/arm/stm32/stm32f4discovery/src/stm32_max31855.c
+++ b/boards/arm/stm32/common/src/stm32_max31855.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * boards/arm/stm32/stm32f4discovery/src/stm32_max31855.c
+ * boards/arm/stm32/common/src/stm32_max31855.c
*
* Copyright (C) 2015 Alan Carvalho de Assis. All rights reserved.
* Author: Alan Carvalho de Assis <ac...@gmail.com>
@@ -41,42 +41,41 @@
#include <errno.h>
#include <debug.h>
+#include <stdio.h>
#include <nuttx/spi/spi.h>
+#include <arch/board/board.h>
#include <nuttx/sensors/max31855.h>
#include "stm32.h"
#include "stm32_spi.h"
-#include "stm32f4discovery.h"
-
-#if defined(CONFIG_SPI) && defined(CONFIG_SENSORS_MAX31855) && defined(CONFIG_STM32_SPI2)
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
- * Name: stm32_max31855initialize
+ * Name: board_max31855_initialize
*
* Description:
* Initialize and register the MAX31855 Temperature Sensor driver.
*
* Input Parameters:
- * devpath - The full path to the driver to register. E.g., "/dev/temp0"
- * bus - Bus number (for hardware that has multiple SPI interfaces)
- * devid - ID associated to the device. E.g., 0, 1, 2, etc.
+ * devno - The device number, used to build the device path as /dev/tempN
+ * busno - The SPI bus number
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
-int stm32_max31855initialize(FAR const char *devpath, int bus, uint16_t devid)
+int board_max31855_initialize(int devno, int busno)
{
FAR struct spi_dev_s *spi;
+ char devpath[12];
int ret;
- spi = stm32_spibus_initialize(bus);
+ spi = stm32_spibus_initialize(busno);
if (!spi)
{
@@ -85,7 +84,8 @@ int stm32_max31855initialize(FAR const char *devpath, int bus, uint16_t devid)
/* Then register the barometer sensor */
- ret = max31855_register(devpath, spi, devid);
+ snprintf(devpath, 12, "/dev/temp%d", devno);
+ ret = max31855_register(devpath, spi, devno);
if (ret < 0)
{
snerr("ERROR: Error registering MAX31855\n");
@@ -93,5 +93,3 @@ int stm32_max31855initialize(FAR const char *devpath, int bus, uint16_t devid)
return ret;
}
-
-#endif /* CONFIG_SPI && CONFIG_SENSORS_MAX31855 */
diff --git a/boards/arm/stm32/stm32f4discovery/src/stm32_mlx90614.c b/boards/arm/stm32/common/src/stm32_mlx90614.c
similarity index 87%
rename from boards/arm/stm32/stm32f4discovery/src/stm32_mlx90614.c
rename to boards/arm/stm32/common/src/stm32_mlx90614.c
index fb2283f..084d8d7 100644
--- a/boards/arm/stm32/stm32f4discovery/src/stm32_mlx90614.c
+++ b/boards/arm/stm32/common/src/stm32_mlx90614.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * boards/arm/stm32/stm32f4discovery/src/stm32_mlx90614.c
+ * boards/arm/stm32/common/src/stm32_mlx90614.c
*
* Copyright (C) 2016 Alan Carvalho de Assis. All rights reserved.
* Author: Alan Carvalho de Assis <ac...@gmail.com>
@@ -41,22 +41,18 @@
#include <errno.h>
#include <debug.h>
+#include <stdio.h>
#include <nuttx/i2c/i2c_master.h>
#include <nuttx/sensors/mlx90614.h>
#include "stm32.h"
#include "stm32_i2c.h"
-#include "stm32f4discovery.h"
-
-#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_MLX90614)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
-#define MLX90614_I2C_PORTNO 1 /* On I2C1 */
-
#define MLX90614_ADDRESS 0x5a /* Default I2C Address, can be chanced in EEPROM */
/****************************************************************************
@@ -64,29 +60,31 @@
****************************************************************************/
/****************************************************************************
- * Name: stm32_mlx90614init
+ * Name: board_mlx90614_initialize
*
* Description:
* Initialize and register the MLX90614 Infrared Thermometer.
*
* Input Parameters:
- * devpath - The full path to the driver to register. E.g., "/dev/therm0"
+ * devno - The device number, used to build the device path as /dev/thermN
+ * busno - The I2C bus number
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
-int stm32_mlx90614init(FAR const char *devpath)
+int board_mlx90614_initialize(int devno, int busno)
{
FAR struct i2c_master_s *i2c;
+ char devpath[12];
int ret;
sninfo("Initializing MLX90614!\n");
/* Initialize I2C */
- i2c = stm32_i2cbus_initialize(MLX90614_I2C_PORTNO);
+ i2c = stm32_i2cbus_initialize(busno);
if (!i2c)
{
@@ -95,6 +93,7 @@ int stm32_mlx90614init(FAR const char *devpath)
/* Then register the light sensor */
+ snprintf(devpath, 12, "/dev/therm%d", devno);
ret = mlx90614_register(devpath, i2c, MLX90614_ADDRESS);
if (ret < 0)
{
@@ -103,5 +102,3 @@ int stm32_mlx90614init(FAR const char *devpath)
return ret;
}
-
-#endif /* CONFIG_I2C && CONFIG_SENSORS_MLX90614 && CONFIG_STM32_I2C1 */
diff --git a/boards/arm/stm32/viewtool-stm32f107/src/stm32_mpl115a.c b/boards/arm/stm32/common/src/stm32_mpl115a.c
similarity index 85%
rename from boards/arm/stm32/viewtool-stm32f107/src/stm32_mpl115a.c
rename to boards/arm/stm32/common/src/stm32_mpl115a.c
index 9c67e11..395738a 100644
--- a/boards/arm/stm32/viewtool-stm32f107/src/stm32_mpl115a.c
+++ b/boards/arm/stm32/common/src/stm32_mpl115a.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * boards/arm/stm32/viewtool-stm32f107/src/stm32_mpl115a.c
+ * boards/arm/stm32/common/src/stm32_mpl115a.c
*
* Copyright (C) 2015 Alan Carvalho de Assis. All rights reserved.
* Author: Alan Carvalho de Assis <ac...@gmail.com>
@@ -41,46 +41,44 @@
#include <errno.h>
#include <debug.h>
+#include <stdio.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_SENSORS_MPL115A) && defined(CONFIG_STM32_SPI3)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
-#define MPL115A_SPI_PORTNO 3 /* On SPI3 */
-
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
- * Name: stm32_mpl115ainitialize
+ * Name: board_mpl115a_initialize
*
* Description:
* Initialize and register the MPL115A Pressure Sensor driver.
*
* Input Parameters:
- * devpath - The full path to the driver to register. E.g., "/dev/press0"
+ * devno - The device number, used to build the device path as /dev/pressN
+ * busno - The SPI bus number
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
-int stm32_mpl115ainitialize(FAR const char *devpath)
+int board_mpl115a_initialize(int devno, int busno)
{
FAR struct spi_dev_s *spi;
+ char devpath[12];
int ret;
- spi = stm32_spibus_initialize(MPL115A_SPI_PORTNO);
+ spi = stm32_spibus_initialize(busno);
if (!spi)
{
@@ -89,6 +87,7 @@ int stm32_mpl115ainitialize(FAR const char *devpath)
/* Then register the barometer sensor */
+ snprintf(devpath, 12, "/dev/press%d", devno);
ret = mpl115a_register(devpath, spi);
if (ret < 0)
{
@@ -97,5 +96,3 @@ int stm32_mpl115ainitialize(FAR const char *devpath)
return ret;
}
-
-#endif /* CONFIG_SPI && CONFIG_SENSORS_MPL115A && CONFIG_STM32_SPI3 */
diff --git a/boards/arm/stm32/stm32f4discovery/src/stm32_xen1210.c b/boards/arm/stm32/common/src/stm32_xen1210.c
similarity index 84%
rename from boards/arm/stm32/stm32f4discovery/src/stm32_xen1210.c
rename to boards/arm/stm32/common/src/stm32_xen1210.c
index 4224fbe..f44e0c8 100644
--- a/boards/arm/stm32/stm32f4discovery/src/stm32_xen1210.c
+++ b/boards/arm/stm32/common/src/stm32_xen1210.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * boards/arm/stm32/stm32f4discovery/src/stm32_xen1210.c
+ * boards/arm/stm32/common/src/stm32_xen1210.c
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Alan Carvalho de Assis <ac...@gmail.com>
@@ -58,35 +58,9 @@
#include "stm32_spi.h"
#include "stm32_pwm.h"
-#include "stm32f4discovery.h"
-
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
-/* Configuration ************************************************************/
-
-#ifdef CONFIG_SENSORS_XEN1210
-#ifndef CONFIG_STM32_SPI1
-# error "XEN1210 support requires CONFIG_STM32_SPI1"
-#endif
-
-#define BOARD_XEN1210_SPIDEV 1
-
-#ifndef BOARD_XEN1210_DEVMINOR
-# define BOARD_XEN1210_DEVMINOR 0
-#endif
-
-#ifndef CONFIG_STM32_TIM1
-# error "XEN1210 needs PWM on TIM1 CH1 to be its clock!"
-#endif
-
-#ifndef CONFIG_STM32_TIM1_PWM
-# error "XEN1210 needs PWM on TIM1 CH1 to be its clock!"
-#endif
-
-#if CONFIG_STM32_TIM1_CHANNEL != XEN1210_PWMCHANNEL
-# error "XEN1210 needs PWM on TIM1 CH1 to be its clock!"
-#endif
/****************************************************************************
* Private Types
@@ -154,7 +128,7 @@ static struct stm32_xen1210config_s g_xen1210config =
/* This is the XEN1210 Interrupt handler */
-int xen1210_interrupt(int irq, FAR void *context, FAR void *arg)
+static int xen1210_interrupt(int irq, FAR void *context, FAR void *arg)
{
/* Verify that we have a handler attached */
@@ -209,15 +183,15 @@ static void xen1210_enable(FAR struct xen1210_config_s *state, bool enable)
{
/* Configure the interrupt using the SAVED handler */
- stm32_configgpio(GPIO_XEN1210_INT);
- stm32_gpiosetevent(GPIO_XEN1210_INT, false, true,
+ stm32_configgpio(BOARD_XEN1210_GPIO_INT);
+ stm32_gpiosetevent(BOARD_XEN1210_GPIO_INT, false, true,
true, xen1210_interrupt, NULL);
}
else
{
/* Configure the interrupt with a NULL handler to disable it */
- stm32_gpiosetevent(GPIO_XEN1210_INT, false, false, false,
+ stm32_gpiosetevent(BOARD_XEN1210_GPIO_INT, false, false, false,
NULL, NULL);
}
@@ -242,7 +216,7 @@ static void xen1210_clear(FAR struct xen1210_config_s *state)
*
****************************************************************************/
-int xen1210_pwm_setup(void)
+static int xen1210_pwm_setup(void)
{
static bool initialized = false;
struct pwm_lowerhalf_s *pwm;
@@ -254,7 +228,7 @@ int xen1210_pwm_setup(void)
{
/* Call stm32_pwminitialize() to get an instance of the PWM interface */
- pwm = stm32_pwminitialize(XEN1210_PWMTIMER);
+ pwm = stm32_pwminitialize(BOARD_XEN1210_PWMTIMER);
if (!pwm)
{
_err("ERROR: Failed to get the STM32 PWM lower half\n");
@@ -283,13 +257,11 @@ int xen1210_pwm_setup(void)
* Name: xen1210_archinitialize
*
* Description:
- * Each board that supports an xen1210 device must provide this function.
- * This function is called by application-specific, setup logic to
- * configure the accelerometer device. This function will register the
- * driver as /dev/accelN where N is the minor device number.
+ * Initialize the XEN1210 device driver
*
* Input Parameters:
- * minor - The input device minor number
+ * devno - The device number, used to build the device path as /dev/accelN
+ * busno - The SPI bus number
*
* Returned Value:
* Zero is returned on success. Otherwise, a negated errno value is
@@ -297,14 +269,11 @@ int xen1210_pwm_setup(void)
*
****************************************************************************/
-int xen1210_archinitialize(int minor)
+int board_xen1210_initialize(int devno, int busno)
{
FAR struct spi_dev_s *dev;
int ret;
- sninfo("minor %d\n", minor);
- DEBUGASSERT(minor == 0);
-
/* Check if we are already initialized */
if (!g_xen1210config.handle)
@@ -319,14 +288,14 @@ int xen1210_archinitialize(int minor)
/* Configure the XEN1210 interrupt pin as an input */
- stm32_configgpio(GPIO_XEN1210_INT);
+ stm32_configgpio(BOARD_XEN1210_GPIO_INT);
/* Get an instance of the I2C interface */
- dev = stm32_spibus_initialize(BOARD_XEN1210_SPIDEV);
+ dev = stm32_spibus_initialize(busno);
if (!dev)
{
- snerr("ERROR: Failed to initialize SPI bus %d\n", BOARD_XEN1210_SPIDEV);
+ snerr("ERROR: Failed to initialize SPI bus %d\n", busno);
return -ENODEV;
}
@@ -342,7 +311,7 @@ int xen1210_archinitialize(int minor)
/* Initialize and register the XEN1210 driver */
- ret = xen1210_register(g_xen1210config.handle, BOARD_XEN1210_DEVMINOR);
+ ret = xen1210_register(g_xen1210config.handle, devno);
if (ret < 0)
{
snerr("ERROR: Failed to register XEN1210 driver: %d\n", ret);
@@ -352,5 +321,3 @@ int xen1210_archinitialize(int minor)
return OK;
}
-
-#endif /* CONFIG_SENSORS_XEN1210 */
diff --git a/boards/arm/stm32/olimex-stm32-p407/include/board.h b/boards/arm/stm32/olimex-stm32-p407/include/board.h
index 2d4adff..de08f0a 100644
--- a/boards/arm/stm32/olimex-stm32-p407/include/board.h
+++ b/boards/arm/stm32/olimex-stm32-p407/include/board.h
@@ -327,4 +327,14 @@
#define DMAMAP_USART6_RX DMAMAP_USART6_RX_1
#define DMAMAP_USART6_TX DMAMAP_USART6_TX_1
+/* DHTxx pin configuration */
+
+#define GPIO_DHTXX_PIN (GPIO_PORTG|GPIO_PIN9)
+#define GPIO_DHTXX_PIN_OUTPUT (GPIO_OUTPUT|GPIO_FLOAT|GPIO_SPEED_100MHz|GPIO_DHTXX_PIN)
+#define GPIO_DHTXX_PIN_INPUT (GPIO_INPUT|GPIO_FLOAT|GPIO_DHTXX_PIN)
+
+#define BOARD_DHTXX_GPIO_INPUT GPIO_DHTXX_PIN_INPUT
+#define BOARD_DHTXX_GPIO_OUTPUT GPIO_DHTXX_PIN_OUTPUT
+#define BOARD_DHTXX_FRTIMER 1 /* Free-run timer 1 */
+
#endif /* __BOARDS_ARM_STM32_OLIMEX_STM32_P407_INCLUDE_BOARD_H */
diff --git a/boards/arm/stm32/olimex-stm32-p407/src/Make.defs b/boards/arm/stm32/olimex-stm32-p407/src/Make.defs
index 748c007..53d9795 100644
--- a/boards/arm/stm32/olimex-stm32-p407/src/Make.defs
+++ b/boards/arm/stm32/olimex-stm32-p407/src/Make.defs
@@ -68,10 +68,6 @@ ifeq ($(CONFIG_CAN),y)
CSRCS += stm32_can.c
endif
-ifeq ($(CONFIG_SENSORS_DHTXX),y)
- CSRCS += stm32_dhtxx.c
-endif
-
DEPPATH += --dep-path board
VPATH += :board
CFLAGS += $(shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board)
diff --git a/boards/arm/stm32/olimex-stm32-p407/src/olimex-stm32-p407.h b/boards/arm/stm32/olimex-stm32-p407/src/olimex-stm32-p407.h
index 17d77f3..f8bee0c 100644
--- a/boards/arm/stm32/olimex-stm32-p407/src/olimex-stm32-p407.h
+++ b/boards/arm/stm32/olimex-stm32-p407/src/olimex-stm32-p407.h
@@ -169,12 +169,6 @@
#define GPIO_BTN_DOWN (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTG|GPIO_PIN8)
#define GPIO_BTN_CENTER (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTG|GPIO_PIN15)
-/* DHTxx pin configuration */
-
-#define GPIO_DHTXX_PIN (GPIO_PORTG|GPIO_PIN9)
-#define GPIO_DHTXX_PIN_OUTPUT (GPIO_OUTPUT|GPIO_FLOAT|GPIO_SPEED_100MHz|GPIO_DHTXX_PIN)
-#define GPIO_DHTXX_PIN_INPUT (GPIO_INPUT|GPIO_FLOAT|GPIO_DHTXX_PIN)
-
/* USB OTG FS
*
* PA9 OTG_FS_VBUS VBUS sensing (also connected to the green LED)
@@ -295,17 +289,5 @@ int stm32_adc_setup(void);
int stm32_can_setup(void);
#endif
-/****************************************************************************
- * Name: stm32_dhtxx_initialize
- *
- * Description:
- * Called to initialize the DHTxx sensor
- *
- ****************************************************************************/
-
-#ifdef CONFIG_SENSORS_DHTXX
-int stm32_dhtxx_initialize(FAR const char *devpath);
-#endif
-
#endif /* __ASSEMBLY__ */
#endif /* __BOARDS_ARM_STM32_OLIMEX_STM32_P407_SRC_H */
diff --git a/boards/arm/stm32/olimex-stm32-p407/src/stm32_bringup.c b/boards/arm/stm32/olimex-stm32-p407/src/stm32_bringup.c
index f7b5636..3a54120 100644
--- a/boards/arm/stm32/olimex-stm32-p407/src/stm32_bringup.c
+++ b/boards/arm/stm32/olimex-stm32-p407/src/stm32_bringup.c
@@ -65,6 +65,10 @@
#include "stm32.h"
#include "olimex-stm32-p407.h"
+#ifdef CONFIG_SENSORS_DHTXX
+#include "stm32_dhtxx.h"
+#endif
+
/****************************************************************************
* Public Data
****************************************************************************/
@@ -201,7 +205,7 @@ int stm32_bringup(void)
#endif
#ifdef CONFIG_SENSORS_DHTXX
- ret = stm32_dhtxx_initialize("/dev/dht0");
+ ret = board_dhtxx_initialize(0);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: stm32_dhtxx_initialize() failed: %d\n", ret);
diff --git a/boards/arm/stm32/stm32f429i-disco/include/board.h b/boards/arm/stm32/stm32f429i-disco/include/board.h
index 16a3a57..83f47bc 100644
--- a/boards/arm/stm32/stm32f429i-disco/include/board.h
+++ b/boards/arm/stm32/stm32f429i-disco/include/board.h
@@ -458,6 +458,19 @@
#endif /* CONFIG_STM32_LTDC */
+/* L3GD20 MEMS */
+
+#define GPIO_L3GD20_DREADY (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTA|GPIO_PIN2)
+#define L3GD20_IRQ (2 + STM32_IRQ_EXTI0)
+
+#define BOARD_L3GD20_GPIO_DREADY GPIO_L3GD20_DREADY
+#define BOARD_L3GD20_IRQ L3GD20_IRQ
+
+#define GPIO_LIS3DSH_EXT0 \
+ (GPIO_INPUT|GPIO_FLOAT|GPIO_AF0|GPIO_SPEED_50MHz|GPIO_PORTE|GPIO_PIN0)
+
+#define BOARD_LIS3DSH_GPIO_EXT0 GPIO_LIS3DSH_EXT0
+
/* DMA ******************************************************************************/
#define ADC1_DMA_CHAN DMAMAP_ADC1_1
diff --git a/boards/arm/stm32/stm32f429i-disco/src/Make.defs b/boards/arm/stm32/stm32f429i-disco/src/Make.defs
index 5480d88..bc7ec06 100644
--- a/boards/arm/stm32/stm32f429i-disco/src/Make.defs
+++ b/boards/arm/stm32/stm32f429i-disco/src/Make.defs
@@ -72,10 +72,6 @@ ifeq ($(CONFIG_STM32F429I_DISCO_ILI9341),y)
CSRCS += stm32_ili93414ws.c
endif
-ifeq ($(CONFIG_SENSORS_L3GD20),y)
-CSRCS += stm32_l3gd20.c
-endif
-
ifeq ($(and \
$(CONFIG_STM32F429I_DISCO_ILI9341_LCDIFACE), \
$(CONFIG_STM32F429I_DISCO_ILI9341_FBIFACE), \
diff --git a/boards/arm/stm32/stm32f429i-disco/src/stm32_bringup.c b/boards/arm/stm32/stm32f429i-disco/src/stm32_bringup.c
index 9c6a638..4947d59 100644
--- a/boards/arm/stm32/stm32f429i-disco/src/stm32_bringup.c
+++ b/boards/arm/stm32/stm32f429i-disco/src/stm32_bringup.c
@@ -81,6 +81,10 @@
#include "stm32.h"
#include "stm32f429i-disco.h"
+#ifdef CONFIG_SENSORS_L3GD20
+#include "stm32_l3gd20.h"
+#endif
+
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -358,7 +362,7 @@ int stm32_bringup(void)
#endif
#ifdef CONFIG_SENSORS_L3GD20
- ret = stm32_l3gd20initialize("/dev/gyr0");
+ ret = board_l3gd20_initialize(0, 5);
if (ret != OK)
{
syslog(LOG_ERR, "ERROR: Failed to initialize l3gd20 sensor: %d\n", ret);
diff --git a/boards/arm/stm32/stm32f429i-disco/src/stm32f429i-disco.h b/boards/arm/stm32/stm32f429i-disco/src/stm32f429i-disco.h
index 8e1fa4f..2673ebd 100644
--- a/boards/arm/stm32/stm32f429i-disco/src/stm32f429i-disco.h
+++ b/boards/arm/stm32/stm32f429i-disco/src/stm32f429i-disco.h
@@ -163,11 +163,6 @@
#define GPIO_CS_SST25 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN4)
-/* L3GD20 MEMS */
-
-#define GPIO_L3GD20_DREADY (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTA|GPIO_PIN2)
-#define L3GD20_IRQ (2 + STM32_IRQ_EXTI0)
-
/* USB OTG HS
*
* PA9 OTG_HS_VBUS VBUS sensing (also connected to the green LED)
diff --git a/boards/arm/stm32/stm32f4discovery/Kconfig b/boards/arm/stm32/stm32f4discovery/Kconfig
index 88fe7c8..f6418a2 100644
--- a/boards/arm/stm32/stm32f4discovery/Kconfig
+++ b/boards/arm/stm32/stm32f4discovery/Kconfig
@@ -55,6 +55,7 @@ config STM32F4DISCO_LIS3DSH
depends on SPI
depends on LIS3DSH
default n
+ select SENSORS_LIS3DSH
---help---
Select to create a LIS3DSH driver instance for the builtin accelerometer of
STM32F4Discovery. Provides /dev/acc0 device file.
diff --git a/boards/arm/stm32/stm32f4discovery/include/board.h b/boards/arm/stm32/stm32f4discovery/include/board.h
index 528f178..2a70b3f 100644
--- a/boards/arm/stm32/stm32f4discovery/include/board.h
+++ b/boards/arm/stm32/stm32f4discovery/include/board.h
@@ -431,4 +431,25 @@
#define BOARD_ZEROCROSS_GPIO \
(GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|GPIO_PORTD|GPIO_PIN0)
+/* LIS3DSH */
+
+#define GPIO_LIS3DSH_EXT0 \
+ (GPIO_INPUT|GPIO_FLOAT|GPIO_AF0|GPIO_SPEED_50MHz|GPIO_PORTE|GPIO_PIN0)
+
+#define BOARD_LIS3DSH_GPIO_EXT0 GPIO_LIS3DSH_EXT0
+
+/* XEN1210 magnetic sensor */
+
+#define GPIO_XEN1210_INT (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|\
+ GPIO_OPENDRAIN|GPIO_PORTA|GPIO_PIN5)
+
+#define GPIO_CS_XEN1210 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
+ GPIO_OUTPUT_SET|GPIO_PORTA|GPIO_PIN4)
+
+#define BOARD_XEN1210_GPIO_INT GPIO_XEN1210_INT
+
+/* Define what timer to use as XEN1210 CLK (will use channel 1) */
+
+#define BOARD_XEN1210_PWMTIMER 1
+
#endif /* __BOARDS_ARM_STM32_STM32F4DISCOVERY_INCLUDE_BOARD_H */
diff --git a/boards/arm/stm32/stm32f4discovery/src/Make.defs b/boards/arm/stm32/stm32f4discovery/src/Make.defs
index 8cf8ed6..82f7217 100644
--- a/boards/arm/stm32/stm32f4discovery/src/Make.defs
+++ b/boards/arm/stm32/stm32f4discovery/src/Make.defs
@@ -65,14 +65,6 @@ ifeq ($(CONFIG_STM32_OTGFS),y)
CSRCS += stm32_usb.c
endif
-ifeq ($(CONFIG_SENSORS_BH1750FVI),y)
-CSRCS += stm32_bh1750fvi.c
-endif
-
-ifeq ($(CONFIG_SENSORS_MLX90614),y)
-CSRCS += stm32_mlx90614.c
-endif
-
ifeq ($(CONFIG_LCD_ST7567),y)
CSRCS += stm32_st7567.c
endif
@@ -85,14 +77,6 @@ ifeq ($(CONFIG_LPWAN_SX127X),y)
CSRCS += stm32_sx127x.c
endif
-ifeq ($(CONFIG_SENSORS_MAX31855),y)
-CSRCS += stm32_max31855.c
-endif
-
-ifeq ($(CONFIG_STM32F4DISCO_LIS3DSH),y)
-CSRCS += stm32_lis3dsh.c
-endif
-
ifeq ($(CONFIG_LCD_MAX7219),y)
CSRCS += stm32_max7219.c
endif
@@ -129,10 +113,6 @@ ifeq ($(CONFIG_PWM),y)
CSRCS += stm32_pwm.c
endif
-ifeq ($(CONFIG_SENSORS_XEN1210),y)
-CSRCS += stm32_xen1210.c
-endif
-
ifeq ($(CONFIG_LIB_BOARDCTL),y)
CSRCS += stm32_appinit.c
ifeq ($(CONFIG_BOARDCTL_RESET),y)
diff --git a/boards/arm/stm32/stm32f4discovery/src/stm32_bringup.c b/boards/arm/stm32/stm32f4discovery/src/stm32_bringup.c
index 517c557..fedd8ec 100644
--- a/boards/arm/stm32/stm32f4discovery/src/stm32_bringup.c
+++ b/boards/arm/stm32/stm32f4discovery/src/stm32_bringup.c
@@ -102,6 +102,26 @@
#include "board_qencoder.h"
#endif
+#ifdef CONFIG_SENSORS_BH1750FVI
+#include "stm32_bh1750.h"
+#endif
+
+#ifdef CONFIG_LIS3DSH
+#include "stm32_lis3dsh.h"
+#endif
+
+#ifdef CONFIG_SENSORS_MAX31855
+#include "stm32_max31855.h"
+#endif
+
+#ifdef CONFIG_SENSORS_MLX90614
+#include "stm32_mlx90614.h"
+#endif
+
+#ifdef CONFIG_SENSORS_XEN1210
+#include "stm32_xen1210.h"
+#endif
+
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -196,7 +216,7 @@ int stm32_bringup(void)
#endif
#ifdef CONFIG_SENSORS_BH1750FVI
- ret = stm32_bh1750initialize("/dev/light0");
+ ret = board_bh1750_initialize(0, 1);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: stm32_bh1750initialize() failed: %d\n", ret);
@@ -338,7 +358,7 @@ int stm32_bringup(void)
#endif
#ifdef CONFIG_SENSORS_MLX90614
- ret = stm32_mlx90614init("/dev/therm0");
+ ret = board_mlx90614_initialize(0, 1);
if (ret < 0)
{
syslog(LOG_ERR, "Failed to initialize MLX90614, error %d\n", ret);
@@ -415,7 +435,7 @@ int stm32_bringup(void)
#ifdef CONFIG_SENSORS_MAX31855
/* Register device 0 on spi channel 2 */
- ret = stm32_max31855initialize("/dev/temp0", 2, 0);
+ ret = board_max31855_initialize(0, 2);
if (ret < 0)
{
serr("ERROR: stm32_max31855initialize failed: %d\n", ret);
@@ -451,19 +471,19 @@ int stm32_bringup(void)
#endif
#ifdef CONFIG_SENSORS_XEN1210
- ret = xen1210_archinitialize(0);
+ ret = board_xen1210_initialize(0, 1);
if (ret < 0)
{
serr("ERROR: xen1210_archinitialize failed: %d\n", ret);
}
#endif
-#ifdef CONFIG_STM32F4DISCO_LIS3DSH
+#ifdef CONFIG_LIS3DSH
/* Create a lis3dsh driver instance fitting the chip built into
* stm32f4discovery
*/
- ret = stm32_lis3dshinitialize("/dev/acc0");
+ ret = board_lis3dsh_initialize(0, 1);
if (ret < 0)
{
serr("ERROR: Failed to initialize LIS3DSH driver: %d\n", ret);
diff --git a/boards/arm/stm32/stm32f4discovery/src/stm32f4discovery.h b/boards/arm/stm32/stm32f4discovery/src/stm32f4discovery.h
index 7be35a0..ac83dae 100644
--- a/boards/arm/stm32/stm32f4discovery/src/stm32f4discovery.h
+++ b/boards/arm/stm32/stm32f4discovery/src/stm32f4discovery.h
@@ -52,11 +52,6 @@
/* Configuration ************************************************************/
-/* Define what timer and channel to use as XEN1210 CLK */
-
-#define XEN1210_PWMTIMER 1
-#define XEN1210_PWMCHANNEL 1
-
/* How many SPI modules does this chip support? */
#if STM32_NSPI < 1
@@ -274,13 +269,6 @@
#define GPIO_GS2200M_CS (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN5)
-/* XEN1210 magnetic sensor */
-
-#define GPIO_XEN1210_INT (GPIO_INPUT|GPIO_FLOAT|GPIO_EXTI|\
- GPIO_OPENDRAIN|GPIO_PORTA|GPIO_PIN5)
-
-#define GPIO_CS_XEN1210 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
- GPIO_OUTPUT_SET|GPIO_PORTA|GPIO_PIN4)
#define GPIO_ENC28J60_CS (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
GPIO_OUTPUT_SET|GPIO_PORTA|GPIO_PIN4)
@@ -467,19 +455,6 @@ int stm32_bh1750initialize(FAR const char *devpath);
#endif
/****************************************************************************
- * Name: stm32_lis3dshinitialize
- *
- * Description:
- * Called to configure SPI 1, and to register LIS3DSH and its external
- * interrupt for the stm32f4discovery board.
- *
- ****************************************************************************/
-
-#ifdef CONFIG_STM32F4DISCO_LIS3DSH
-int stm32_lis3dshinitialize(FAR const char *devpath);
-#endif
-
-/****************************************************************************
* Name: stm32_lpwaninitialize
*
* Description:
diff --git a/boards/arm/stm32/viewtool-stm32f107/src/Make.defs b/boards/arm/stm32/viewtool-stm32f107/src/Make.defs
index 2218838..1900662 100644
--- a/boards/arm/stm32/viewtool-stm32f107/src/Make.defs
+++ b/boards/arm/stm32/viewtool-stm32f107/src/Make.defs
@@ -54,10 +54,6 @@ CSRCS += stm32_usbdev.c
endif
endif
-ifeq ($(CONFIG_SENSORS_MPL115A),y)
-CSRCS += stm32_mpl115a.c
-endif
-
ifeq ($(CONFIG_INPUT_ADS7843E),y) # F103
CSRCS += stm32_ads7843e.c
endif
diff --git a/boards/arm/stm32/viewtool-stm32f107/src/stm32_bringup.c b/boards/arm/stm32/viewtool-stm32f107/src/stm32_bringup.c
index ac81557..05d667c 100644
--- a/boards/arm/stm32/viewtool-stm32f107/src/stm32_bringup.c
+++ b/boards/arm/stm32/viewtool-stm32f107/src/stm32_bringup.c
@@ -54,6 +54,10 @@
#include "viewtool_stm32f107.h"
+#ifdef CONFIG_SENSORS_MPL115A
+#include "stm32_mpl115a.h"
+#endif
+
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@@ -186,7 +190,7 @@ int stm32_bringup(void)
#endif
#ifdef CONFIG_SENSORS_MPL115A
- ret = stm32_mpl115ainitialize("/dev/press");
+ ret = board_mpl115a_initialize(0, 5);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: stm32_mpl115ainitialize failed: %d\n", ret);
diff --git a/drivers/sensors/l3gd20.c b/drivers/sensors/l3gd20.c
index eca6526..f392365 100644
--- a/drivers/sensors/l3gd20.c
+++ b/drivers/sensors/l3gd20.c
@@ -89,8 +89,10 @@ struct l3gd20_dev_s
* Private Function Prototypes
****************************************************************************/
+#ifdef CONFIG_DEBUG_SENSORS_INFO
static void l3gd20_read_register(FAR struct l3gd20_dev_s *dev,
uint8_t const reg_addr, uint8_t *reg_data);
+#endif
static void l3gd20_write_register(FAR struct l3gd20_dev_s *dev,
uint8_t const reg_addr,
uint8_t const reg_data);
@@ -101,7 +103,8 @@ static void l3gd20_read_gyroscope_data(FAR struct l3gd20_dev_s *dev,
uint16_t *z_gyr);
static void l3gd20_read_temperature(FAR struct l3gd20_dev_s *dev,
uint8_t * temperature);
-static int l3gd20_interrupt_handler(int irq, FAR void *context);
+static int l3gd20_interrupt_handler(int irq, FAR void *context,
+ FAR void *arg);
static void l3gd20_worker(FAR void *arg);
static int l3gd20_open(FAR struct file *filep);
@@ -138,6 +141,7 @@ static struct l3gd20_dev_s *g_l3gd20_list = NULL;
* Private Functions
****************************************************************************/
+#ifdef CONFIG_DEBUG_SENSORS_INFO
/****************************************************************************
* Name: l3gd20_read_register
****************************************************************************/
@@ -171,6 +175,7 @@ static void l3gd20_read_register(FAR struct l3gd20_dev_s *dev,
SPI_LOCK(dev->spi, false);
}
+#endif
/****************************************************************************
* Name: l3gd20_write_register
@@ -342,7 +347,8 @@ static void l3gd20_read_temperature(FAR struct l3gd20_dev_s *dev,
* Name: l3gd20_interrupt_handler
****************************************************************************/
-static int l3gd20_interrupt_handler(int irq, FAR void *context)
+static int l3gd20_interrupt_handler(int irq, FAR void *context,
+ FAR void *arg)
{
/* This function should be called upon a rising edge on the L3GD20 new data
* interrupt pin since it signals that new data has been measured.
diff --git a/drivers/sensors/lis3dsh.c b/drivers/sensors/lis3dsh.c
index aeeac2e..e98f296 100644
--- a/drivers/sensors/lis3dsh.c
+++ b/drivers/sensors/lis3dsh.c
@@ -86,8 +86,11 @@ struct lis3dsh_dev_s
* Private Function Prototypes
****************************************************************************/
+#ifdef CONFIG_DEBUG_SENSORS_INFO
static void lis3dsh_read_register(FAR struct lis3dsh_dev_s *dev,
uint8_t const reg_addr, uint8_t *reg_data);
+#endif
+
static void lis3dsh_write_register(FAR struct lis3dsh_dev_s *dev,
uint8_t const reg_addr,
uint8_t const reg_data);
@@ -96,7 +99,8 @@ static void lis3dsh_read_measurement_data(FAR struct lis3dsh_dev_s *dev);
static void lis3dsh_read_acclerometer_data(FAR struct lis3dsh_dev_s *dev,
uint16_t *x_acc, uint16_t *y_acc,
uint16_t *z_acc);
-static int lis3dsh_interrupt_handler(int irq, FAR void *context);
+static int lis3dsh_interrupt_handler(int irq, FAR void *context,
+ FAR void *arg);
static void lis3dsh_worker(FAR void *arg);
static int lis3dsh_open(FAR struct file *filep);
@@ -133,6 +137,7 @@ static struct lis3dsh_dev_s *g_lis3dsh_list = NULL;
* Private Functions
****************************************************************************/
+#ifdef CONFIG_DEBUG_SENSORS_INFO
/****************************************************************************
* Name: lis3dsh_read_register
****************************************************************************/
@@ -166,6 +171,7 @@ static void lis3dsh_read_register(FAR struct lis3dsh_dev_s *dev,
SPI_LOCK(dev->spi, false);
}
+#endif
/****************************************************************************
* Name: lis3dsh_write_register
@@ -296,7 +302,8 @@ static void lis3dsh_read_acclerometer_data(FAR struct lis3dsh_dev_s *dev,
* Name: lis3dsh_interrupt_handler
****************************************************************************/
-static int lis3dsh_interrupt_handler(int irq, FAR void *context)
+static int lis3dsh_interrupt_handler(int irq, FAR void *context,
+ FAR void *arg)
{
/* This function should be called upon a rising edge on the LIS3DSH new data
* interrupt pin since it signals that new data has been measured.
@@ -309,7 +316,7 @@ static int lis3dsh_interrupt_handler(int irq, FAR void *context)
for (priv = g_lis3dsh_list;
priv && priv->config->irq != irq;
- priv = priv->flink);
+ priv = priv->flink)
{
}