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 d444df59af7d9866dc464e14b0ce33b2552022d1
Author: Matias Nitsche <[email protected]>
AuthorDate: Fri May 8 13:17:28 2020 -0300

    stm32: move APA102, VEML6070 and MAX6675 initialization to board common 
logic
---
 boards/arm/stm32/common/include/stm32_apa102.h     |  84 ++++++++++++++++
 boards/arm/stm32/common/include/stm32_max6675.h    |  84 ++++++++++++++++
 boards/arm/stm32/common/include/stm32_veml6070.h   |  85 ++++++++++++++++
 boards/arm/stm32/common/src/Make.defs              |  12 +++
 boards/arm/stm32/common/src/stm32_apa102.c         | 108 ++++++++++++++++++++
 boards/arm/stm32/common/src/stm32_max6675.c        | 102 +++++++++++++++++++
 boards/arm/stm32/common/src/stm32_veml6070.c       | 112 +++++++++++++++++++++
 boards/arm/stm32/stm32f103-minimum/src/Make.defs   |  12 ---
 .../arm/stm32/stm32f103-minimum/src/stm32_apa102.c | 103 -------------------
 .../stm32/stm32f103-minimum/src/stm32_bringup.c    |  18 +++-
 .../stm32/stm32f103-minimum/src/stm32_max6675.c    | 101 -------------------
 .../stm32/stm32f103-minimum/src/stm32_veml6070.c   | 105 -------------------
 boards/arm/stm32/stm32f4discovery/src/Make.defs    |   4 -
 .../arm/stm32/stm32f4discovery/src/stm32_bringup.c |   6 +-
 .../arm/stm32/stm32f4discovery/src/stm32_max6675.c | 101 -------------------
 15 files changed, 607 insertions(+), 430 deletions(-)

diff --git a/boards/arm/stm32/common/include/stm32_apa102.h 
b/boards/arm/stm32/common/include/stm32_apa102.h
new file mode 100644
index 0000000..4d7516f
--- /dev/null
+++ b/boards/arm/stm32/common/include/stm32_apa102.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+ * boards/arm/stm32/common/include/stm32_apa102.h
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __STM32_APA102_H
+#define __STM32_APA102_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Type Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Inline Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_apa102_initialize
+ *
+ * Description:
+ *   Initialize and register the APA102 LED Strip driver.
+ *
+ * Input Parameters:
+ *   devno - The device number, used to build the device path as /dev/leddrvN
+ *   spino - SPI port number
+ *
+ * Returned Value:
+ *   Zero (OK) on success; a negated errno value on failure.
+ *
+ ****************************************************************************/
+
+int board_apa102_initialize(int devno, int spino);
+
+#undef EXTERN
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __STM32_APA102_H
diff --git a/boards/arm/stm32/common/include/stm32_max6675.h 
b/boards/arm/stm32/common/include/stm32_max6675.h
new file mode 100644
index 0000000..d96f5f1
--- /dev/null
+++ b/boards/arm/stm32/common/include/stm32_max6675.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+ * boards/arm/stm32/common/include/stm32_max6675.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __STM32_MAX6675_C
+#define __STM32_MAX6675_C
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Type Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Inline Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_max6675_initialize
+ *
+ * Description:
+ *   Initialize and register the MAX6675 Temperature Sensor driver.
+ *
+ * Input Parameters:
+ *   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_max6675_initialize(int devno, int busno);
+
+#undef EXTERN
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __STM32_MAX6675_C
diff --git a/boards/arm/stm32/common/include/stm32_veml6070.h 
b/boards/arm/stm32/common/include/stm32_veml6070.h
new file mode 100644
index 0000000..77ca033
--- /dev/null
+++ b/boards/arm/stm32/common/include/stm32_veml6070.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+ * boards/arm/stm32/common/include/stm32_veml6070.h
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __STM32_VEML6070_H
+#define __STM32_VEML6070_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Type Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Inline Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_veml6070_initialize
+ *
+ * Description:
+ *   Initialize and register the VEML6070 UV-A Light sensor.
+ *
+ * Input Parameters:
+ *   devno - The device number, used to build the device path as
+ *           /dev/uvlightN
+ *   busno - The I2C bus number
+ *
+ * Returned Value:
+ *   Zero (OK) on success; a negated errno value on failure.
+ *
+ ****************************************************************************/
+
+int board_veml6070_initialize(int devno, int busno);
+
+#undef EXTERN
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __STM32_VEML6070_H
diff --git a/boards/arm/stm32/common/src/Make.defs 
b/boards/arm/stm32/common/src/Make.defs
index 592055b..7737743 100644
--- a/boards/arm/stm32/common/src/Make.defs
+++ b/boards/arm/stm32/common/src/Make.defs
@@ -22,6 +22,18 @@ ifeq ($(CONFIG_SENSORS_BMP180),y)
   CSRCS += stm32_bmp180.c
 endif
 
+ifeq ($(CONFIG_LEDS_APA102),y)
+  CSRCS += stm32_apa102.c
+endif
+
+ifeq ($(CONFIG_SENSORS_MAX6675),y)
+  CSRCS += stm32_max6675.c
+endif
+
+ifeq ($(CONFIG_SENSORS_VEML6070),y)
+  CSRCS += stm32_veml6070.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/common/src/stm32_apa102.c 
b/boards/arm/stm32/common/src/stm32_apa102.c
new file mode 100644
index 0000000..37f0bd1
--- /dev/null
+++ b/boards/arm/stm32/common/src/stm32_apa102.c
@@ -0,0 +1,108 @@
+/****************************************************************************
+ * boards/arm/stm32/common/src/stm32_apa102.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <errno.h>
+#include <debug.h>
+#include <stdio.h>
+
+#include <nuttx/spi/spi.h>
+#include <nuttx/leds/apa102.h>
+
+#include "stm32.h"
+#include "stm32_spi.h"
+
+#ifdef CONFIG_LEDS_APA102
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_apa102_initialize
+ *
+ * Description:
+ *   Initialize and register the APA102 LED Strip driver.
+ *
+ * Input Parameters:
+ *   devno - The device number, used to build the device path as /dev/leddrvN
+ *   spino - SPI port number
+ *
+ * Returned Value:
+ *   Zero (OK) on success; a negated errno value on failure.
+ *
+ ****************************************************************************/
+
+int board_apa102_initialize(int devno, int spino)
+{
+  FAR struct spi_dev_s *spi;
+  char devpath[12];
+  int ret;
+
+  spi = stm32_spibus_initialize(spino);
+  if (spi == NULL)
+    {
+      return -ENODEV;
+    }
+
+  /* Register the APA102 Driver at the specified location. */
+
+  snprintf(devpath, 12, "/dev/leddrv%d", devno);
+  ret = apa102_register(devpath, spi);
+  if (ret < 0)
+    {
+      lederr("ERROR: apa102_register(%s) failed: %d\n",
+             devpath, ret);
+      return ret;
+    }
+
+  return OK;
+}
+
+#endif
diff --git a/boards/arm/stm32/common/src/stm32_max6675.c 
b/boards/arm/stm32/common/src/stm32_max6675.c
new file mode 100644
index 0000000..fe39879
--- /dev/null
+++ b/boards/arm/stm32/common/src/stm32_max6675.c
@@ -0,0 +1,102 @@
+/****************************************************************************
+ * boards/arm/stm32/common/src/stm32_max6675.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/arch.h>
+#include <nuttx/sensors/max6675.h>
+#include <nuttx/spi/spi.h>
+#include <stdio.h>
+#include "stm32_spi.h"
+
+#ifdef CONFIG_SENSORS_MAX6675
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_max6675_initialize
+ *
+ * Description:
+ *   Initialize and register the MAX6675 Temperature Sensor driver.
+ *
+ * Input Parameters:
+ *   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_max6675_initialize(int devno, int busno)
+{
+  FAR struct spi_dev_s *spi;
+  char devpath[12];
+  int ret;
+
+  spi = stm32_spibus_initialize(busno);
+
+  if (!spi)
+    {
+      return -ENODEV;
+    }
+
+  /* Then register the barometer sensor */
+
+  snprintf(devpath, 12, "/dev/temp%d", devno);
+  ret = max6675_register(devpath, spi);
+  if (ret < 0)
+    {
+      snerr("ERROR: Error registering MAX6675\n");
+    }
+
+  return ret;
+}
+
+#endif
diff --git a/boards/arm/stm32/common/src/stm32_veml6070.c 
b/boards/arm/stm32/common/src/stm32_veml6070.c
new file mode 100644
index 0000000..a2850f1
--- /dev/null
+++ b/boards/arm/stm32/common/src/stm32_veml6070.c
@@ -0,0 +1,112 @@
+/****************************************************************************
+ * boards/arm/stm32/common/src/stm32_veml6070.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdio.h>
+#include <errno.h>
+#include <debug.h>
+
+#include <nuttx/spi/spi.h>
+#include <nuttx/sensors/veml6070.h>
+
+#include "stm32.h"
+#include "stm32_i2c.h"
+
+#ifdef CONFIG_SENSORS_VEML6070
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_veml6070_initialize
+ *
+ * Description:
+ *   Initialize and register the VEML6070 UV-A Light sensor.
+ *
+ * Input Parameters:
+ *   devno - The device number, used to build the device path as
+ *           /dev/uvlightN
+ *   busno - The I2C bus number
+ *
+ * Returned Value:
+ *   Zero (OK) on success; a negated errno value on failure.
+ *
+ ****************************************************************************/
+
+int board_veml6070_initialize(int devno, int busno)
+{
+  FAR struct i2c_master_s *i2c;
+  char devpath[13];
+  int ret;
+
+  sninfo("Initializing VEML6070!\n");
+
+  /* Initialize I2C */
+
+  i2c = stm32_i2cbus_initialize(busno);
+
+  if (!i2c)
+    {
+      return -ENODEV;
+    }
+
+  /* Then register the light sensor */
+
+  snprintf(devpath, 13, "/dev/uvlight%d", devno);
+  ret = veml6070_register(devpath, i2c, VEML6070_I2C_DATA_LSB_CMD_ADDR);
+  if (ret < 0)
+    {
+      snerr("ERROR: Error registering VEML6070\n");
+    }
+
+  return ret;
+}
+
+#endif
diff --git a/boards/arm/stm32/stm32f103-minimum/src/Make.defs 
b/boards/arm/stm32/stm32f103-minimum/src/Make.defs
index c4bb6df..b4bf184 100644
--- a/boards/arm/stm32/stm32f103-minimum/src/Make.defs
+++ b/boards/arm/stm32/stm32f103-minimum/src/Make.defs
@@ -73,10 +73,6 @@ ifeq ($(CONFIG_LCD_BACKPACK),y)
   CSRCS += stm32_lcd_backpack.c
 endif
 
-ifeq ($(CONFIG_LEDS_APA102),y)
-  CSRCS += stm32_apa102.c
-endif
-
 ifeq ($(CONFIG_LM75_I2C),y)
   CSRCS += stm32_lm75.c
 endif
@@ -115,10 +111,6 @@ ifeq ($(CONFIG_SENSORS_HCSR04),y)
   CSRCS += stm32_hcsr04.c
 endif
 
-ifeq ($(CONFIG_SENSORS_MAX6675),y)
-  CSRCS += stm32_max6675.c
-endif
-
 ifeq ($(CONFIG_LCD_MAX7219),y)
   CSRCS += stm32_max7219.c
 endif
@@ -147,10 +139,6 @@ ifeq ($(CONFIG_SENSORS_QENCODER),y)
   CSRCS += stm32_qencoder.c
 endif
 
-ifeq ($(CONFIG_SENSORS_VEML6070),y)
-  CSRCS += stm32_veml6070.c
-endif
-
 ifeq ($(CONFIG_WL_NRF24L01),y)
   CSRCS += stm32_nrf24l01.c
 endif
diff --git a/boards/arm/stm32/stm32f103-minimum/src/stm32_apa102.c 
b/boards/arm/stm32/stm32f103-minimum/src/stm32_apa102.c
deleted file mode 100644
index f14f00c..0000000
--- a/boards/arm/stm32/stm32f103-minimum/src/stm32_apa102.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/****************************************************************************
- * boards/arm/stm32/stm32f103-minium/src/stm32_apa102.c
- *
- *   Copyright (C) 2017 Alan Carvalho de Assis. All rights reserved.
- *   Author: Alan Carvalho de Assis <[email protected]>
- *
- * 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/leds/apa102.h>
-
-#include "stm32.h"
-#include "stm32_spi.h"
-#include "stm32f103_minimum.h"
-
-#if defined(CONFIG_SPI) && defined(CONFIG_STM32_SPI1) && \
-    defined(CONFIG_LEDS_APA102)
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-#define APA102_SPI_PORTNO 1   /* On SPI1 */
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: stm32_apa102init
- *
- * Description:
- *   Initialize and register the APA102 LED Strip driver.
- *
- * Input Parameters:
- *   devpath - The full path to the driver to register. E.g., "/dev/leddrv0"
- *
- * Returned Value:
- *   Zero (OK) on success; a negated errno value on failure.
- *
- ****************************************************************************/
-
-int stm32_apa102init(FAR const char *devpath)
-{
-  FAR struct spi_dev_s *spi;
-  int ret;
-
-  spi = stm32_spibus_initialize(APA102_SPI_PORTNO);
-  if (spi == NULL)
-    {
-      return -ENODEV;
-    }
-
-  /* Register the APA102 Driver at the specified location. */
-
-  ret = apa102_register(devpath, spi);
-  if (ret < 0)
-    {
-      lederr("ERROR: apa102_register(%s) failed: %d\n",
-             devpath, ret);
-      return ret;
-    }
-
-  return OK;
-}
-
-#endif /* CONFIG_SPI && CONFIG_CAN_APA102 */
diff --git a/boards/arm/stm32/stm32f103-minimum/src/stm32_bringup.c 
b/boards/arm/stm32/stm32f103-minimum/src/stm32_bringup.c
index 03bfa35..8312d36 100644
--- a/boards/arm/stm32/stm32f103-minimum/src/stm32_bringup.c
+++ b/boards/arm/stm32/stm32f103-minimum/src/stm32_bringup.c
@@ -89,6 +89,18 @@
 #include "stm32_bmp180.h"
 #endif
 
+#ifdef CONFIG_LEDS_APA102
+#include "stm32_apa102.h"
+#endif
+
+#ifdef CONFIG_SENSORS_MAX6675
+#include "stm32_max6675.h"
+#endif
+
+#ifdef CONFIG_SENSORS_VEML6070
+#include "stm32_veml6070.h"
+#endif
+
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
@@ -264,7 +276,7 @@ int stm32_bringup(void)
 #ifdef CONFIG_LEDS_APA102
   /* Configure and initialize the APA102 LED Strip. */
 
-  ret = stm32_apa102init("/dev/leddrv0");
+  ret = board_apa102_initialize(0, 1);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: stm32_apa102init() failed: %d\n", ret);
@@ -302,7 +314,7 @@ int stm32_bringup(void)
 #endif
 
 #ifdef CONFIG_SENSORS_MAX6675
-  ret = stm32_max6675initialize("/dev/temp0");
+  ret = board_max6675_initialize(0, 1);
   if (ret < 0)
     {
       serr("ERROR:  stm32_max6675initialize failed: %d\n", ret);
@@ -391,7 +403,7 @@ int stm32_bringup(void)
 #ifdef CONFIG_SENSORS_VEML6070
   /* Register the UV-A light sensor */
 
-  ret = stm32_veml6070initialize("/dev/uvlight0");
+  ret = board_veml6070_initialize(0, 1);
   if (ret < 0)
     {
       syslog(LOG_ERR, "ERROR: stm32_veml6070initialize() failed: %d\n", ret);
diff --git a/boards/arm/stm32/stm32f103-minimum/src/stm32_max6675.c 
b/boards/arm/stm32/stm32f103-minimum/src/stm32_max6675.c
deleted file mode 100644
index 23b79e3..0000000
--- a/boards/arm/stm32/stm32f103-minimum/src/stm32_max6675.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/****************************************************************************
- * boards/arm/stm32/stm32f4discovery/src/stm32_max6675.c
- *
- *   Copyright (C) 2018 Alan Carvalho de Assis. All rights reserved.
- *   Author: Alan Carvalho de Assis <[email protected]>
- *
- * 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/max6675.h>
-
-#include "stm32.h"
-#include "stm32_spi.h"
-#include "stm32f103_minimum.h"
-
-#if defined(CONFIG_SPI) && defined(CONFIG_SENSORS_MAX6675) && 
defined(CONFIG_STM32_SPI1)
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-#define MAX6675_SPI_PORTNO 1   /* On SPI1 */
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: stm32_max6675initialize
- *
- * Description:
- *   Initialize and register the MAX6675 Temperature Sensor driver.
- *
- * Input Parameters:
- *   devpath - The full path to the driver to register. E.g., "/dev/temp0"
- *
- * Returned Value:
- *   Zero (OK) on success; a negated errno value on failure.
- *
- ****************************************************************************/
-
-int stm32_max6675initialize(FAR const char *devpath)
-{
-  FAR struct spi_dev_s *spi;
-  int ret;
-
-  spi = stm32_spibus_initialize(MAX6675_SPI_PORTNO);
-
-  if (!spi)
-    {
-      return -ENODEV;
-    }
-
-  /* Then register the barometer sensor */
-
-  ret = max6675_register(devpath, spi);
-  if (ret < 0)
-    {
-      snerr("ERROR: Error registering MAX6675\n");
-    }
-
-  return ret;
-}
-
-#endif /* CONFIG_SPI && CONFIG_SENSORS_MAX6675 */
diff --git a/boards/arm/stm32/stm32f103-minimum/src/stm32_veml6070.c 
b/boards/arm/stm32/stm32f103-minimum/src/stm32_veml6070.c
deleted file mode 100644
index c7dd4ae..0000000
--- a/boards/arm/stm32/stm32f103-minimum/src/stm32_veml6070.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
- * boards/arm/stm32/stm32f103-minimum/src/stm32_veml6070.c
- *
- *   Copyright (C) 2016 Alan Carvalho de Assis. All rights reserved.
- *   Author: Alan Carvalho de Assis <[email protected]>
- *
- * 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/veml6070.h>
-
-#include "stm32.h"
-#include "stm32_i2c.h"
-#include "stm32f103_minimum.h"
-
-#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_VEML6070)
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-#define VEML6070_I2C_PORTNO 1   /* On I2C1 */
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: stm32_veml6070initialize
- *
- * Description:
- *   Initialize and register the VEML6070 UV-A Light sensor.
- *
- * Input Parameters:
- *   devpath - The full path to the driver to register. E.g., "/dev/uvlight0"
- *
- * Returned Value:
- *   Zero (OK) on success; a negated errno value on failure.
- *
- ****************************************************************************/
-
-int stm32_veml6070initialize(FAR const char *devpath)
-{
-  FAR struct i2c_master_s *i2c;
-  int ret;
-
-  sninfo("Initializing VEML6070!\n");
-
-  /* Initialize I2C */
-
-  i2c = stm32_i2cbus_initialize(VEML6070_I2C_PORTNO);
-
-  if (!i2c)
-    {
-      return -ENODEV;
-    }
-
-  /* Then register the light sensor */
-
-  ret = veml6070_register(devpath, i2c, VEML6070_I2C_DATA_LSB_CMD_ADDR);
-  if (ret < 0)
-    {
-      snerr("ERROR: Error registering VEML6070\n");
-    }
-
-  return ret;
-}
-
-#endif /* CONFIG_I2C && CONFIG_SENSORS_VEML6070 && CONFIG_STM32_I2C1 */
diff --git a/boards/arm/stm32/stm32f4discovery/src/Make.defs 
b/boards/arm/stm32/stm32f4discovery/src/Make.defs
index eefa4a4..6c12413 100644
--- a/boards/arm/stm32/stm32f4discovery/src/Make.defs
+++ b/boards/arm/stm32/stm32f4discovery/src/Make.defs
@@ -97,10 +97,6 @@ ifeq ($(CONFIG_STM32F4DISCO_LIS3DSH),y)
 CSRCS += stm32_lis3dsh.c
 endif
 
-ifeq ($(CONFIG_SENSORS_MAX6675),y)
-CSRCS += stm32_max6675.c
-endif
-
 ifeq ($(CONFIG_LCD_MAX7219),y)
 CSRCS += stm32_max7219.c
 endif
diff --git a/boards/arm/stm32/stm32f4discovery/src/stm32_bringup.c 
b/boards/arm/stm32/stm32f4discovery/src/stm32_bringup.c
index 98903cc..8e4aebb 100644
--- a/boards/arm/stm32/stm32f4discovery/src/stm32_bringup.c
+++ b/boards/arm/stm32/stm32f4discovery/src/stm32_bringup.c
@@ -86,6 +86,10 @@
 #include "stm32_bmp180.h"
 #endif
 
+#ifdef CONFIG_SENSORS_MAX6675
+#include "stm32_max6675.h"
+#endif
+
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
@@ -407,7 +411,7 @@ int stm32_bringup(void)
 #endif
 
 #ifdef CONFIG_SENSORS_MAX6675
-  ret = stm32_max6675initialize("/dev/temp0");
+  ret = board_max6675_initialize(0, 2);
   if (ret < 0)
     {
       serr("ERROR:  stm32_max6675initialize failed: %d\n", ret);
diff --git a/boards/arm/stm32/stm32f4discovery/src/stm32_max6675.c 
b/boards/arm/stm32/stm32f4discovery/src/stm32_max6675.c
deleted file mode 100644
index 4e30c2c..0000000
--- a/boards/arm/stm32/stm32f4discovery/src/stm32_max6675.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/****************************************************************************
- * boards/arm/stm32/stm32f4discovery/src/stm32_max6675.c
- *
- *   Copyright (C) 2015 Alan Carvalho de Assis. All rights reserved.
- *   Author: Alan Carvalho de Assis <[email protected]>
- *
- * 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/max6675.h>
-
-#include "stm32.h"
-#include "stm32_spi.h"
-#include "stm32f4discovery.h"
-
-#if defined(CONFIG_SPI) && defined(CONFIG_SENSORS_MAX6675) && 
defined(CONFIG_STM32_SPI2)
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-#define MAX6675_SPI_PORTNO 2   /* On SPI2 */
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: stm32_max6675initialize
- *
- * Description:
- *   Initialize and register the MAX6675 Temperature Sensor driver.
- *
- * Input Parameters:
- *   devpath - The full path to the driver to register. E.g., "/dev/temp0"
- *
- * Returned Value:
- *   Zero (OK) on success; a negated errno value on failure.
- *
- ****************************************************************************/
-
-int stm32_max6675initialize(FAR const char *devpath)
-{
-  FAR struct spi_dev_s *spi;
-  int ret;
-
-  spi = stm32_spibus_initialize(MAX6675_SPI_PORTNO);
-
-  if (!spi)
-    {
-      return -ENODEV;
-    }
-
-  /* Then register the barometer sensor */
-
-  ret = max6675_register(devpath, spi);
-  if (ret < 0)
-    {
-      snerr("ERROR: Error registering MAX6675\n");
-    }
-
-  return ret;
-}
-
-#endif /* CONFIG_SPI && CONFIG_SENSORS_MAX6675 */

Reply via email to