From 4fdf2520e6f492cbca2144fb7098bb7c76ccc4ca Mon Sep 17 00:00:00 2001 From: Matias Nitsche Date: Mon, 11 May 2020 19:20:55 -0300 Subject: [PATCH] stm32: move qencoder initialization to common board logic --- .../arm/stm32/common/include/board_qencoder.h | 74 +++++++++++++++++ boards/arm/stm32/common/src/Make.defs | 4 + .../src/stm32_qencoder.c | 17 ++-- boards/arm/stm32/mikroe-stm32f4/src/Make.defs | 4 - .../stm32/mikroe-stm32f4/src/mikroe-stm32f4.h | 12 --- .../stm32/mikroe-stm32f4/src/stm32_appinit.c | 6 +- .../stm32/mikroe-stm32f4/src/stm32_qencoder.c | 82 ------------------ boards/arm/stm32/nucleo-f446re/src/Make.defs | 4 - .../stm32/nucleo-f446re/src/nucleo-f446re.h | 12 --- .../stm32/nucleo-f446re/src/stm32_appinit.c | 6 +- .../stm32/nucleo-f446re/src/stm32_qencoder.c | 82 ------------------ boards/arm/stm32/nucleo-f4x1re/src/Make.defs | 4 - .../stm32/nucleo-f4x1re/src/nucleo-f4x1re.h | 12 --- .../stm32/nucleo-f4x1re/src/stm32_bringup.c | 6 +- .../stm32/nucleo-f4x1re/src/stm32_qencoder.c | 83 ------------------- boards/arm/stm32/stm3240g-eval/src/Make.defs | 4 - .../arm/stm32/stm32f103-minimum/src/Make.defs | 4 - .../stm32f103-minimum/src/stm32_bringup.c | 6 +- .../stm32f103-minimum/src/stm32f103_minimum.h | 12 --- .../arm/stm32/stm32f3discovery/src/Make.defs | 4 - .../stm32f3discovery/src/stm32_bringup.c | 6 +- .../stm32f3discovery/src/stm32_qencoder.c | 82 ------------------ .../stm32f3discovery/src/stm32f3discovery.h | 12 --- .../arm/stm32/stm32f4discovery/src/Make.defs | 4 - .../stm32f4discovery/src/stm32_bringup.c | 6 +- .../stm32f4discovery/src/stm32_qencoder.c | 80 ------------------ .../stm32f4discovery/src/stm32f4discovery.h | 12 --- .../arm/stm32/stm32ldiscovery/src/Make.defs | 4 - .../stm32/stm32ldiscovery/src/stm32_bringup.c | 6 +- .../stm32ldiscovery/src/stm32_qencoder.c | 82 ------------------ .../stm32ldiscovery/src/stm32ldiscovery.h | 12 --- 31 files changed, 122 insertions(+), 622 deletions(-) create mode 100644 boards/arm/stm32/common/include/board_qencoder.h rename boards/arm/stm32/{stm32f103-minimum => common}/src/stm32_qencoder.c (88%) delete mode 100644 boards/arm/stm32/mikroe-stm32f4/src/stm32_qencoder.c delete mode 100644 boards/arm/stm32/nucleo-f446re/src/stm32_qencoder.c delete mode 100644 boards/arm/stm32/nucleo-f4x1re/src/stm32_qencoder.c delete mode 100644 boards/arm/stm32/stm32f3discovery/src/stm32_qencoder.c delete mode 100644 boards/arm/stm32/stm32f4discovery/src/stm32_qencoder.c delete mode 100644 boards/arm/stm32/stm32ldiscovery/src/stm32_qencoder.c diff --git a/boards/arm/stm32/common/include/board_qencoder.h b/boards/arm/stm32/common/include/board_qencoder.h new file mode 100644 index 0000000000..9aee53c7e5 --- /dev/null +++ b/boards/arm/stm32/common/include/board_qencoder.h @@ -0,0 +1,74 @@ +/**************************************************************************** + * boards/arm/stm32/common/include/stm32_qencoder.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_QENCODER_H +#define __STM32_QENCODER_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor 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_qencoder_initialize + * + * Description: + * Initialize the quadrature encoder driver for the given timer + * + ****************************************************************************/ + +int board_qencoder_initialize(int devno, int timerno); + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif // __STM32_QENCODER_H diff --git a/boards/arm/stm32/common/src/Make.defs b/boards/arm/stm32/common/src/Make.defs index ee95f29504..1d8d75d1a4 100644 --- a/boards/arm/stm32/common/src/Make.defs +++ b/boards/arm/stm32/common/src/Make.defs @@ -66,6 +66,10 @@ ifeq ($(CONFIG_SENSORS_ZEROCROSS),y) CSRCS += stm32_zerocross.c endif +ifeq ($(CONFIG_SENSORS_QENCODER),y) + CSRCS += stm32_qencoder.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/stm32f103-minimum/src/stm32_qencoder.c b/boards/arm/stm32/common/src/stm32_qencoder.c similarity index 88% rename from boards/arm/stm32/stm32f103-minimum/src/stm32_qencoder.c rename to boards/arm/stm32/common/src/stm32_qencoder.c index 49b9bb74a8..222f019bee 100644 --- a/boards/arm/stm32/stm32f103-minimum/src/stm32_qencoder.c +++ b/boards/arm/stm32/common/src/stm32_qencoder.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32/stm32f103-minimum/src/stm32_qencoder.c + * boards/arm/stm32/common/src/stm32_qencoder.c * * Copyright (C) 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -41,6 +41,7 @@ #include #include +#include #include #include @@ -48,29 +49,29 @@ #include "chip.h" #include "arm_arch.h" #include "stm32_qencoder.h" -#include "stm32f103_minimum.h" /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** - * Name: stm32_qencoder_initialize + * Name: board_qencoder_initialize * * Description: - * All STM32 architectures must provide the following interface to work with - * examples/qencoder. + * Initialize the quadrature encoder driver for the given timer * ****************************************************************************/ -int stm32_qencoder_initialize(FAR const char *devpath, int timer) +int board_qencoder_initialize(int devno, int timerno) { int ret; + char devpath[12]; /* Initialize a quadrature encoder interface. */ - sninfo("Initializing the quadrature encoder using TIM%d\n", timer); - ret = stm32_qeinitialize(devpath, timer); + sninfo("Initializing the quadrature encoder using TIM%d\n", timerno); + snprintf(devpath, 12, "/dev/qe%d", devno); + ret = stm32_qeinitialize(devpath, timerno); if (ret < 0) { snerr("ERROR: stm32_qeinitialize failed: %d\n", ret); diff --git a/boards/arm/stm32/mikroe-stm32f4/src/Make.defs b/boards/arm/stm32/mikroe-stm32f4/src/Make.defs index 844ebe25e0..4312038bd0 100644 --- a/boards/arm/stm32/mikroe-stm32f4/src/Make.defs +++ b/boards/arm/stm32/mikroe-stm32f4/src/Make.defs @@ -54,10 +54,6 @@ ifeq ($(CONFIG_PWM),y) CSRCS += stm32_pwm.c endif -ifeq ($(CONFIG_SENSORS_QENCODER),y) -CSRCS += stm32_qencoder.c -endif - ifeq ($(CONFIG_LIB_BOARDCTL),y) CSRCS += stm32_appinit.c endif diff --git a/boards/arm/stm32/mikroe-stm32f4/src/mikroe-stm32f4.h b/boards/arm/stm32/mikroe-stm32f4/src/mikroe-stm32f4.h index 5958e7e9f2..ab4687749e 100644 --- a/boards/arm/stm32/mikroe-stm32f4/src/mikroe-stm32f4.h +++ b/boards/arm/stm32/mikroe-stm32f4/src/mikroe-stm32f4.h @@ -252,18 +252,6 @@ int stm32_pwm_setup(void); # error "The Mikroe-STM32F4 board does not support HOST OTG, only device!" #endif -/**************************************************************************** - * Name: stm32_qencoder_initialize - * - * Description: - * Initialize and register a qencoder - * - ****************************************************************************/ - -#ifdef CONFIG_SENSORS_QENCODER -int stm32_qencoder_initialize(FAR const char *devpath, int timer); -#endif - /**************************************************************************** * Name: stm32_lcdinitialize * diff --git a/boards/arm/stm32/mikroe-stm32f4/src/stm32_appinit.c b/boards/arm/stm32/mikroe-stm32f4/src/stm32_appinit.c index e705b7c318..fb61c4db52 100644 --- a/boards/arm/stm32/mikroe-stm32f4/src/stm32_appinit.c +++ b/boards/arm/stm32/mikroe-stm32f4/src/stm32_appinit.c @@ -76,6 +76,10 @@ #include "stm32.h" #include "mikroe-stm32f4.h" +#ifdef CONFIG_SENSORS_QENCODER +#include "board_qencoder.h" +#endif + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -385,7 +389,7 @@ int board_app_initialize(uintptr_t arg) #ifdef CONFIG_SENSORS_QENCODER /* Initialize and register the qencoder driver */ - ret = stm32_qencoder_initialize("/dev/qe0", CONFIG_MIKROE_QETIMER); + ret = board_qencoder_initialize(0, CONFIG_MIKROE_QETIMER); if (ret != OK) { syslog(LOG_ERR, diff --git a/boards/arm/stm32/mikroe-stm32f4/src/stm32_qencoder.c b/boards/arm/stm32/mikroe-stm32f4/src/stm32_qencoder.c deleted file mode 100644 index 654be4b249..0000000000 --- a/boards/arm/stm32/mikroe-stm32f4/src/stm32_qencoder.c +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32/mikroe_stm32f4/src/stm32_qencoder.c - * - * Copyright (C) 2012-2013, 2016 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include - -#include -#include - -#include "chip.h" -#include "arm_arch.h" -#include "stm32_qencoder.h" -#include "mikroe-stm32f4.h" - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: stm32_qencoder_initialize - * - * Description: - * All STM32 architectures must provide the following interface to work with - * examples/qencoder. - * - ****************************************************************************/ - -int stm32_qencoder_initialize(FAR const char *devpath, int timer) -{ - int ret; - - /* Initialize a quadrature encoder interface. */ - - sninfo("Initializing the quadrature encoder using TIM%d\n", timer); - ret = stm32_qeinitialize(devpath, timer); - if (ret < 0) - { - snerr("ERROR: stm32_qeinitialize failed: %d\n", ret); - } - - return ret; -} - -#endif /* HAVE_QENCODER */ diff --git a/boards/arm/stm32/nucleo-f446re/src/Make.defs b/boards/arm/stm32/nucleo-f446re/src/Make.defs index 06c61d93ef..395328c0c2 100644 --- a/boards/arm/stm32/nucleo-f446re/src/Make.defs +++ b/boards/arm/stm32/nucleo-f446re/src/Make.defs @@ -55,10 +55,6 @@ CSRCS += stm32_ajoystick.c endif endif -ifeq ($(CONFIG_SENSORS_QENCODER),y) -CSRCS += stm32_qencoder.c -endif - ifeq ($(CONFIG_NSH_LIBRARY),y) CSRCS += stm32_appinit.c endif diff --git a/boards/arm/stm32/nucleo-f446re/src/nucleo-f446re.h b/boards/arm/stm32/nucleo-f446re/src/nucleo-f446re.h index db8a00eb8f..a19ef1d28d 100644 --- a/boards/arm/stm32/nucleo-f446re/src/nucleo-f446re.h +++ b/boards/arm/stm32/nucleo-f446re/src/nucleo-f446re.h @@ -260,18 +260,6 @@ void stm32_usbinitialize(void); int stm32_adc_setup(void); #endif -/**************************************************************************** - * Name: stm32_qencoder_initialize - * - * Description: - * Initialize and register a qencoder - * - ****************************************************************************/ - -#ifdef CONFIG_SENSORS_QENCODER -int stm32_qencoder_initialize(FAR const char *devpath, int timer); -#endif - /**************************************************************************** * Name: board_ajoy_initialize * diff --git a/boards/arm/stm32/nucleo-f446re/src/stm32_appinit.c b/boards/arm/stm32/nucleo-f446re/src/stm32_appinit.c index d4c4020297..7789425854 100644 --- a/boards/arm/stm32/nucleo-f446re/src/stm32_appinit.c +++ b/boards/arm/stm32/nucleo-f446re/src/stm32_appinit.c @@ -55,6 +55,10 @@ #include "nucleo-f446re.h" +#ifdef CONFIG_SENSORS_QENCODER +#include "board_qencoder.h" +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -132,7 +136,7 @@ int board_app_initialize(uintptr_t arg) #ifdef CONFIG_SENSORS_QENCODER /* Initialize and register the qencoder driver */ - ret = stm32_qencoder_initialize("/dev/qe0", CONFIG_NUCLEO_F401RE_QETIMER); + ret = board_qencoder_initialize(0, CONFIG_NUCLEO_F401RE_QETIMER); if (ret != OK) { syslog(LOG_ERR, diff --git a/boards/arm/stm32/nucleo-f446re/src/stm32_qencoder.c b/boards/arm/stm32/nucleo-f446re/src/stm32_qencoder.c deleted file mode 100644 index 4f6e6e37ef..0000000000 --- a/boards/arm/stm32/nucleo-f446re/src/stm32_qencoder.c +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32/nucleo-f446re/src/stm32_qencoder.c - * - * Copyright (C) 2019 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/***************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include - -#include -#include - -#include "chip.h" -#include "arm_arch.h" -#include "stm32_qencoder.h" -#include "nucleo-f446re.h" - -/***************************************************************************** - * Public Functions - ****************************************************************************/ - -/***************************************************************************** - * Name: stm32_qencoder_initialize - * - * Description: - * All STM32 architectures must provide the following interface to work - * with examples/qencoder. - * - ****************************************************************************/ - -int stm32_qencoder_initialize(FAR const char *devpath, int timer) -{ - int ret; - - /* Initialize a quadrature encoder interface. */ - - sninfo("Initializing the quadrature encoder using TIM%d\n", timer); - ret = stm32_qeinitialize(devpath, timer); - if (ret < 0) - { - snerr("ERROR: stm32_qeinitialize failed: %d\n", ret); - } - - return ret; -} - -#endif /* HAVE_QENCODER */ diff --git a/boards/arm/stm32/nucleo-f4x1re/src/Make.defs b/boards/arm/stm32/nucleo-f4x1re/src/Make.defs index 273f635f5d..d38cb8b0ac 100644 --- a/boards/arm/stm32/nucleo-f4x1re/src/Make.defs +++ b/boards/arm/stm32/nucleo-f4x1re/src/Make.defs @@ -55,10 +55,6 @@ CSRCS += stm32_ajoystick.c endif endif -ifeq ($(CONFIG_SENSORS_QENCODER),y) -CSRCS += stm32_qencoder.c -endif - ifeq ($(CONFIG_CAN_MCP2515),y) CSRCS += stm32_mcp2515.c endif diff --git a/boards/arm/stm32/nucleo-f4x1re/src/nucleo-f4x1re.h b/boards/arm/stm32/nucleo-f4x1re/src/nucleo-f4x1re.h index 91bd54e5a9..750c148195 100644 --- a/boards/arm/stm32/nucleo-f4x1re/src/nucleo-f4x1re.h +++ b/boards/arm/stm32/nucleo-f4x1re/src/nucleo-f4x1re.h @@ -288,18 +288,6 @@ void stm32_usbinitialize(void); int stm32_adc_setup(void); #endif -/**************************************************************************** - * Name: stm32_qencoder_initialize - * - * Description: - * Initialize and register a qencoder - * - ****************************************************************************/ - -#ifdef CONFIG_SENSORS_QENCODER -int stm32_qencoder_initialize(FAR const char *devpath, int timer); -#endif - /**************************************************************************** * Name: board_ajoy_initialize * diff --git a/boards/arm/stm32/nucleo-f4x1re/src/stm32_bringup.c b/boards/arm/stm32/nucleo-f4x1re/src/stm32_bringup.c index a30f82e272..c9e015ed65 100644 --- a/boards/arm/stm32/nucleo-f4x1re/src/stm32_bringup.c +++ b/boards/arm/stm32/nucleo-f4x1re/src/stm32_bringup.c @@ -56,6 +56,10 @@ #include +#ifdef CONFIG_SENSORS_QENCODER +#include "board_qencoder.h" +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -151,7 +155,7 @@ int stm32_bringup(void) #ifdef CONFIG_SENSORS_QENCODER /* Initialize and register the qencoder driver */ - ret = stm32_qencoder_initialize("/dev/qe0", CONFIG_NUCLEO_F401RE_QETIMER); + ret = board_qencoder_initialize(0, CONFIG_NUCLEO_F401RE_QETIMER); if (ret != OK) { syslog(LOG_ERR, diff --git a/boards/arm/stm32/nucleo-f4x1re/src/stm32_qencoder.c b/boards/arm/stm32/nucleo-f4x1re/src/stm32_qencoder.c deleted file mode 100644 index e5b7edaea5..0000000000 --- a/boards/arm/stm32/nucleo-f4x1re/src/stm32_qencoder.c +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32/nucleo-f4x1re/src/stm32_qencoder.c - * - * Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include - -#include - -#include "chip.h" -#include "arm_arch.h" -#include "stm32_qencoder.h" -#include "nucleo-f4x1re.h" - -#include - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: stm32_qencoder_initialize - * - * Description: - * All STM32 architectures must provide the following interface to work with - * examples/qencoder. - * - ****************************************************************************/ - -int stm32_qencoder_initialize(FAR const char *devpath, int timer) -{ - int ret; - - /* Initialize a quadrature encoder interface. */ - - sninfo("Initializing the quadrature encoder using TIM%d\n", timer); - ret = stm32_qeinitialize(devpath, timer); - if (ret < 0) - { - snerr("ERROR: stm32_qeinitialize failed: %d\n", ret); - } - - return ret; -} - -#endif /* HAVE_QENCODER */ diff --git a/boards/arm/stm32/stm3240g-eval/src/Make.defs b/boards/arm/stm32/stm3240g-eval/src/Make.defs index 0b8ccecd0c..c56e111355 100644 --- a/boards/arm/stm32/stm3240g-eval/src/Make.defs +++ b/boards/arm/stm32/stm3240g-eval/src/Make.defs @@ -81,10 +81,6 @@ ifeq ($(CONFIG_INPUT_STMPE811),y) CSRCS += stm32_stmpe811.c endif -ifeq ($(CONFIG_SENSORS_QENCODER),y) -CSRCS += stm32_qencoder.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/stm32f103-minimum/src/Make.defs b/boards/arm/stm32/stm32f103-minimum/src/Make.defs index 87829af8cc..b8d3c262b8 100644 --- a/boards/arm/stm32/stm32f103-minimum/src/Make.defs +++ b/boards/arm/stm32/stm32f103-minimum/src/Make.defs @@ -115,10 +115,6 @@ ifeq ($(CONFIG_LCD_PCD8544),y) CSRCS += stm32_pcd8544.c endif -ifeq ($(CONFIG_SENSORS_QENCODER),y) - CSRCS += stm32_qencoder.c -endif - ifeq ($(CONFIG_USBDEV),y) CSRCS += stm32_usbdev.c endif diff --git a/boards/arm/stm32/stm32f103-minimum/src/stm32_bringup.c b/boards/arm/stm32/stm32f103-minimum/src/stm32_bringup.c index b01e1ade48..efa651034e 100644 --- a/boards/arm/stm32/stm32f103-minimum/src/stm32_bringup.c +++ b/boards/arm/stm32/stm32f103-minimum/src/stm32_bringup.c @@ -129,6 +129,10 @@ #include "stm32_zerocross.h" #endif +#ifdef CONFIG_SENSORS_QENCODER +#include "board_qencoder.h" +#endif + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -402,7 +406,7 @@ int stm32_bringup(void) #ifdef CONFIG_SENSORS_QENCODER /* Initialize and register the qencoder driver */ - ret = stm32_qencoder_initialize("/dev/qe0", + ret = board_qencoder_initialize(0, CONFIG_STM32F103MINIMUM_QETIMER); if (ret != OK) { diff --git a/boards/arm/stm32/stm32f103-minimum/src/stm32f103_minimum.h b/boards/arm/stm32/stm32f103-minimum/src/stm32f103_minimum.h index 6031556f7c..03abbc86bc 100644 --- a/boards/arm/stm32/stm32f103-minimum/src/stm32f103_minimum.h +++ b/boards/arm/stm32/stm32f103-minimum/src/stm32f103_minimum.h @@ -292,18 +292,6 @@ int stm32_max6675initialize(FAR const char *devpath); int stm32_w25initialize(int minor); -/**************************************************************************** - * Name: stm32_qencoder_initialize - * - * Description: - * Initialize and register a qencoder - * - ****************************************************************************/ - -#ifdef CONFIG_SENSORS_QENCODER -int stm32_qencoder_initialize(FAR const char *devpath, int timer); -#endif - /**************************************************************************** * Name: stm32_rgbled_setup * diff --git a/boards/arm/stm32/stm32f3discovery/src/Make.defs b/boards/arm/stm32/stm32f3discovery/src/Make.defs index 37cf3189d2..66b8eea474 100644 --- a/boards/arm/stm32/stm32f3discovery/src/Make.defs +++ b/boards/arm/stm32/stm32f3discovery/src/Make.defs @@ -60,10 +60,6 @@ ifeq ($(CONFIG_PWM),y) CSRCS += stm32_pwm.c endif -ifeq ($(CONFIG_SENSORS_QENCODER),y) -CSRCS += stm32_qencoder.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/stm32f3discovery/src/stm32_bringup.c b/boards/arm/stm32/stm32f3discovery/src/stm32_bringup.c index bac522630e..894d43a5ca 100644 --- a/boards/arm/stm32/stm32f3discovery/src/stm32_bringup.c +++ b/boards/arm/stm32/stm32f3discovery/src/stm32_bringup.c @@ -53,6 +53,10 @@ #include "stm32.h" #include "stm32f3discovery.h" +#ifdef CONFIG_SENSORS_QENCODER +#include "board_qencoder.h" +#endif + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -129,7 +133,7 @@ int stm32_bringup(void) #ifdef CONFIG_SENSORS_QENCODER /* Initialize and register the qencoder driver */ - ret = stm32_qencoder_initialize("/dev/qe0", CONFIG_STM32F3DISCO_QETIMER); + ret = board_qencoder_initialize(0, CONFIG_STM32F3DISCO_QETIMER); if (ret != OK) { syslog(LOG_ERR, diff --git a/boards/arm/stm32/stm32f3discovery/src/stm32_qencoder.c b/boards/arm/stm32/stm32f3discovery/src/stm32_qencoder.c deleted file mode 100644 index d29c72bdc2..0000000000 --- a/boards/arm/stm32/stm32f3discovery/src/stm32_qencoder.c +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32/stm32f3discovery/src/stm32_qencoder.c - * - * Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include - -#include -#include - -#include "chip.h" -#include "arm_arch.h" -#include "stm32_qencoder.h" -#include "stm32f3discovery.h" - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: stm32_qencoder_initialize - * - * Description: - * All STM32 architectures must provide the following interface to work with - * examples/qencoder. - * - ****************************************************************************/ - -int stm32_qencoder_initialize(FAR const char *devpath, int timer) -{ - int ret; - - /* Initialize a quadrature encoder interface. */ - - sninfo("Initializing the quadrature encoder using TIM%d\n", timer); - ret = stm32_qeinitialize(devpath, timer); - if (ret < 0) - { - snerr("ERROR: stm32_qeinitialize failed: %d\n", ret); - } - - return ret; -} - -#endif /* HAVE_QENCODER */ diff --git a/boards/arm/stm32/stm32f3discovery/src/stm32f3discovery.h b/boards/arm/stm32/stm32f3discovery/src/stm32f3discovery.h index 8d33b452c3..109c12d6ce 100644 --- a/boards/arm/stm32/stm32f3discovery/src/stm32f3discovery.h +++ b/boards/arm/stm32/stm32f3discovery/src/stm32f3discovery.h @@ -193,17 +193,5 @@ void weak_function stm32_usbinitialize(void); int stm32_pwm_setup(void); #endif -/**************************************************************************** - * Name: stm32_qencoder_initialize - * - * Description: - * Initialize and register a qencoder - * - ****************************************************************************/ - -#ifdef CONFIG_SENSORS_QENCODER -int stm32_qencoder_initialize(FAR const char *devpath, int timer); -#endif - #endif /* __ASSEMBLY__ */ #endif /* __BOARDS_ARM_STM32_STM32F3DISCOVERY_SRC_STM32F3DISCOVERY_H */ diff --git a/boards/arm/stm32/stm32f4discovery/src/Make.defs b/boards/arm/stm32/stm32f4discovery/src/Make.defs index 03464111b4..8cf8ed6e26 100644 --- a/boards/arm/stm32/stm32f4discovery/src/Make.defs +++ b/boards/arm/stm32/stm32f4discovery/src/Make.defs @@ -129,10 +129,6 @@ ifeq ($(CONFIG_PWM),y) CSRCS += stm32_pwm.c endif -ifeq ($(CONFIG_SENSORS_QENCODER),y) -CSRCS += stm32_qencoder.c -endif - ifeq ($(CONFIG_SENSORS_XEN1210),y) CSRCS += stm32_xen1210.c endif diff --git a/boards/arm/stm32/stm32f4discovery/src/stm32_bringup.c b/boards/arm/stm32/stm32f4discovery/src/stm32_bringup.c index 0c0ef80144..517c55782a 100644 --- a/boards/arm/stm32/stm32f4discovery/src/stm32_bringup.c +++ b/boards/arm/stm32/stm32f4discovery/src/stm32_bringup.c @@ -98,6 +98,10 @@ #include "stm32_zerocross.h" #endif +#ifdef CONFIG_SENSORS_QENCODER +#include "board_qencoder.h" +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -345,7 +349,7 @@ int stm32_bringup(void) #ifdef CONFIG_SENSORS_QENCODER /* Initialize and register the qencoder driver */ - ret = stm32_qencoder_initialize("/dev/qe0", CONFIG_STM32F4DISCO_QETIMER); + ret = board_qencoder_initialize(0, CONFIG_STM32F4DISCO_QETIMER); if (ret != OK) { syslog(LOG_ERR, diff --git a/boards/arm/stm32/stm32f4discovery/src/stm32_qencoder.c b/boards/arm/stm32/stm32f4discovery/src/stm32_qencoder.c deleted file mode 100644 index 3d58ec1588..0000000000 --- a/boards/arm/stm32/stm32f4discovery/src/stm32_qencoder.c +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32/stm32f4discovery/src/stm32_qencoder.c - * - * Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include - -#include -#include - -#include "chip.h" -#include "arm_arch.h" -#include "stm32_qencoder.h" -#include "stm32f4discovery.h" - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: stm32_qencoder_initialize - * - * Description: - * All STM32 architectures must provide the following interface to work with - * examples/qencoder. - * - ****************************************************************************/ - -int stm32_qencoder_initialize(FAR const char *devpath, int timer) -{ - int ret; - - /* Initialize a quadrature encoder interface. */ - - sninfo("Initializing the quadrature encoder using TIM%d\n", timer); - ret = stm32_qeinitialize(devpath, timer); - if (ret < 0) - { - snerr("ERROR: stm32_qeinitialize failed: %d\n", ret); - } - - return ret; -} diff --git a/boards/arm/stm32/stm32f4discovery/src/stm32f4discovery.h b/boards/arm/stm32/stm32f4discovery/src/stm32f4discovery.h index ff95944a23..7be35a0261 100644 --- a/boards/arm/stm32/stm32f4discovery/src/stm32f4discovery.h +++ b/boards/arm/stm32/stm32f4discovery/src/stm32f4discovery.h @@ -686,18 +686,6 @@ int stm32_sdio_initialize(void); void weak_function stm32_netinitialize(void); #endif -/**************************************************************************** - * Name: stm32_qencoder_initialize - * - * Description: - * Initialize and register a qencoder - * - ****************************************************************************/ - -#ifdef CONFIG_SENSORS_QENCODER -int stm32_qencoder_initialize(FAR const char *devpath, int timer); -#endif - /**************************************************************************** * Name: stm32_zerocross_initialize * diff --git a/boards/arm/stm32/stm32ldiscovery/src/Make.defs b/boards/arm/stm32/stm32ldiscovery/src/Make.defs index 06dd127df2..ae3dfefa2b 100644 --- a/boards/arm/stm32/stm32ldiscovery/src/Make.defs +++ b/boards/arm/stm32/stm32ldiscovery/src/Make.defs @@ -56,10 +56,6 @@ ifeq ($(CONFIG_PWM),y) CSRCS += stm32_pwm.c endif -ifeq ($(CONFIG_SENSORS_QENCODER),y) -CSRCS += stm32_qencoder.c -endif - ifeq ($(CONFIG_LIB_BOARDCTL),y) CSRCS += stm32_appinit.c endif diff --git a/boards/arm/stm32/stm32ldiscovery/src/stm32_bringup.c b/boards/arm/stm32/stm32ldiscovery/src/stm32_bringup.c index 3016a92ba9..ad6d370a76 100644 --- a/boards/arm/stm32/stm32ldiscovery/src/stm32_bringup.c +++ b/boards/arm/stm32/stm32ldiscovery/src/stm32_bringup.c @@ -48,6 +48,10 @@ #include "stm32ldiscovery.h" +#ifdef CONFIG_SENSORS_QENCODER +#include "board_qencoder.h" +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -104,7 +108,7 @@ int stm32_bringup(void) #ifdef CONFIG_SENSORS_QENCODER /* Initialize and register the qencoder driver */ - ret = stm32_qencoder_initialize("/dev/qe0", CONFIG_STM32LDISCO_QETIMER); + ret = board_qencoder_initialize(0, CONFIG_STM32LDISCO_QETIMER); if (ret != OK) { syslog(LOG_ERR, diff --git a/boards/arm/stm32/stm32ldiscovery/src/stm32_qencoder.c b/boards/arm/stm32/stm32ldiscovery/src/stm32_qencoder.c deleted file mode 100644 index 260fb8aedc..0000000000 --- a/boards/arm/stm32/stm32ldiscovery/src/stm32_qencoder.c +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32/stm32ldiscovery/src/up_qencoder.c - * - * Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include - -#include -#include - -#include "chip.h" -#include "arm_arch.h" -#include "stm32_qencoder.h" -#include "stm32ldiscovery.h" - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: stm32_qencoder_initialize - * - * Description: - * All STM32 architectures must provide the following interface to work with - * examples/qencoder. - * - ****************************************************************************/ - -int stm32_qencoder_initialize(FAR const char *devpath, int timer) -{ - int ret; - - /* Initialize a quadrature encoder interface. */ - - sninfo("Initializing the quadrature encoder using TIM%d\n", timer); - ret = stm32_qeinitialize(devpath, timer); - if (ret < 0) - { - snerr("ERROR: stm32_qeinitialize failed: %d\n", ret); - } - - return ret; -} - -#endif /* HAVE_QENCODER */ diff --git a/boards/arm/stm32/stm32ldiscovery/src/stm32ldiscovery.h b/boards/arm/stm32/stm32ldiscovery/src/stm32ldiscovery.h index b9aa2d7572..4663261919 100644 --- a/boards/arm/stm32/stm32ldiscovery/src/stm32ldiscovery.h +++ b/boards/arm/stm32/stm32ldiscovery/src/stm32ldiscovery.h @@ -277,17 +277,5 @@ void weak_function stm32_spidev_initialize(void); int stm32_pwm_setup(void); #endif -/**************************************************************************** - * Name: stm32_qencoder_initialize - * - * Description: - * Initialize and register a qencoder - * - ****************************************************************************/ - -#ifdef CONFIG_SENSORS_QENCODER -int stm32_qencoder_initialize(FAR const char *devpath, int timer); -#endif - #endif /* __ASSEMBLY__ */ #endif /* __BOARDS_ARM_STM32_STM32F3DISCOVERY_SRC_STM32F3DISCOVERY_H */