mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
stm32: move qencoder initialization to common board logic
This commit is contained in:
committed by
Alin Jerpelea
parent
856c3e4263
commit
4fdf2520e6
@@ -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 <nuttx/config.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* 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
|
||||||
@@ -66,6 +66,10 @@ ifeq ($(CONFIG_SENSORS_ZEROCROSS),y)
|
|||||||
CSRCS += stm32_zerocross.c
|
CSRCS += stm32_zerocross.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_SENSORS_QENCODER),y)
|
||||||
|
CSRCS += stm32_qencoder.c
|
||||||
|
endif
|
||||||
|
|
||||||
DEPPATH += --dep-path src
|
DEPPATH += --dep-path src
|
||||||
VPATH += :src
|
VPATH += :src
|
||||||
CFLAGS += $(shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src)
|
CFLAGS += $(shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src)
|
||||||
|
|||||||
+9
-8
@@ -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.
|
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
@@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <nuttx/sensors/qencoder.h>
|
#include <nuttx/sensors/qencoder.h>
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
@@ -48,29 +49,29 @@
|
|||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
#include "arm_arch.h"
|
#include "arm_arch.h"
|
||||||
#include "stm32_qencoder.h"
|
#include "stm32_qencoder.h"
|
||||||
#include "stm32f103_minimum.h"
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: stm32_qencoder_initialize
|
* Name: board_qencoder_initialize
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* All STM32 architectures must provide the following interface to work with
|
* Initialize the quadrature encoder driver for the given timer
|
||||||
* examples/qencoder.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int stm32_qencoder_initialize(FAR const char *devpath, int timer)
|
int board_qencoder_initialize(int devno, int timerno)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
char devpath[12];
|
||||||
|
|
||||||
/* Initialize a quadrature encoder interface. */
|
/* Initialize a quadrature encoder interface. */
|
||||||
|
|
||||||
sninfo("Initializing the quadrature encoder using TIM%d\n", timer);
|
sninfo("Initializing the quadrature encoder using TIM%d\n", timerno);
|
||||||
ret = stm32_qeinitialize(devpath, timer);
|
snprintf(devpath, 12, "/dev/qe%d", devno);
|
||||||
|
ret = stm32_qeinitialize(devpath, timerno);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
snerr("ERROR: stm32_qeinitialize failed: %d\n", ret);
|
snerr("ERROR: stm32_qeinitialize failed: %d\n", ret);
|
||||||
@@ -54,10 +54,6 @@ ifeq ($(CONFIG_PWM),y)
|
|||||||
CSRCS += stm32_pwm.c
|
CSRCS += stm32_pwm.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_SENSORS_QENCODER),y)
|
|
||||||
CSRCS += stm32_qencoder.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_LIB_BOARDCTL),y)
|
ifeq ($(CONFIG_LIB_BOARDCTL),y)
|
||||||
CSRCS += stm32_appinit.c
|
CSRCS += stm32_appinit.c
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -252,18 +252,6 @@ int stm32_pwm_setup(void);
|
|||||||
# error "The Mikroe-STM32F4 board does not support HOST OTG, only device!"
|
# error "The Mikroe-STM32F4 board does not support HOST OTG, only device!"
|
||||||
#endif
|
#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
|
* Name: stm32_lcdinitialize
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -76,6 +76,10 @@
|
|||||||
#include "stm32.h"
|
#include "stm32.h"
|
||||||
#include "mikroe-stm32f4.h"
|
#include "mikroe-stm32f4.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_SENSORS_QENCODER
|
||||||
|
#include "board_qencoder.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -385,7 +389,7 @@ int board_app_initialize(uintptr_t arg)
|
|||||||
#ifdef CONFIG_SENSORS_QENCODER
|
#ifdef CONFIG_SENSORS_QENCODER
|
||||||
/* Initialize and register the qencoder driver */
|
/* 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)
|
if (ret != OK)
|
||||||
{
|
{
|
||||||
syslog(LOG_ERR,
|
syslog(LOG_ERR,
|
||||||
|
|||||||
@@ -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 <gnutt@nuttx.org>
|
|
||||||
*
|
|
||||||
* 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/sensors/qencoder.h>
|
|
||||||
#include <arch/board/board.h>
|
|
||||||
|
|
||||||
#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 */
|
|
||||||
@@ -55,10 +55,6 @@ CSRCS += stm32_ajoystick.c
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_SENSORS_QENCODER),y)
|
|
||||||
CSRCS += stm32_qencoder.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_NSH_LIBRARY),y)
|
ifeq ($(CONFIG_NSH_LIBRARY),y)
|
||||||
CSRCS += stm32_appinit.c
|
CSRCS += stm32_appinit.c
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -260,18 +260,6 @@ void stm32_usbinitialize(void);
|
|||||||
int stm32_adc_setup(void);
|
int stm32_adc_setup(void);
|
||||||
#endif
|
#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
|
* Name: board_ajoy_initialize
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -55,6 +55,10 @@
|
|||||||
|
|
||||||
#include "nucleo-f446re.h"
|
#include "nucleo-f446re.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_SENSORS_QENCODER
|
||||||
|
#include "board_qencoder.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -132,7 +136,7 @@ int board_app_initialize(uintptr_t arg)
|
|||||||
#ifdef CONFIG_SENSORS_QENCODER
|
#ifdef CONFIG_SENSORS_QENCODER
|
||||||
/* Initialize and register the qencoder driver */
|
/* 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)
|
if (ret != OK)
|
||||||
{
|
{
|
||||||
syslog(LOG_ERR,
|
syslog(LOG_ERR,
|
||||||
|
|||||||
@@ -1,82 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* boards/arm/stm32/nucleo-f446re/src/stm32_qencoder.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
|
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
*
|
|
||||||
* 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/sensors/qencoder.h>
|
|
||||||
#include <arch/board/board.h>
|
|
||||||
|
|
||||||
#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 */
|
|
||||||
@@ -55,10 +55,6 @@ CSRCS += stm32_ajoystick.c
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_SENSORS_QENCODER),y)
|
|
||||||
CSRCS += stm32_qencoder.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_CAN_MCP2515),y)
|
ifeq ($(CONFIG_CAN_MCP2515),y)
|
||||||
CSRCS += stm32_mcp2515.c
|
CSRCS += stm32_mcp2515.c
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -288,18 +288,6 @@ void stm32_usbinitialize(void);
|
|||||||
int stm32_adc_setup(void);
|
int stm32_adc_setup(void);
|
||||||
#endif
|
#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
|
* Name: board_ajoy_initialize
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -56,6 +56,10 @@
|
|||||||
|
|
||||||
#include <nuttx/board.h>
|
#include <nuttx/board.h>
|
||||||
|
|
||||||
|
#ifdef CONFIG_SENSORS_QENCODER
|
||||||
|
#include "board_qencoder.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -151,7 +155,7 @@ int stm32_bringup(void)
|
|||||||
#ifdef CONFIG_SENSORS_QENCODER
|
#ifdef CONFIG_SENSORS_QENCODER
|
||||||
/* Initialize and register the qencoder driver */
|
/* 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)
|
if (ret != OK)
|
||||||
{
|
{
|
||||||
syslog(LOG_ERR,
|
syslog(LOG_ERR,
|
||||||
|
|||||||
@@ -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 <gnutt@nuttx.org>
|
|
||||||
*
|
|
||||||
* 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/sensors/qencoder.h>
|
|
||||||
|
|
||||||
#include "chip.h"
|
|
||||||
#include "arm_arch.h"
|
|
||||||
#include "stm32_qencoder.h"
|
|
||||||
#include "nucleo-f4x1re.h"
|
|
||||||
|
|
||||||
#include <arch/board/board.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 */
|
|
||||||
@@ -81,10 +81,6 @@ ifeq ($(CONFIG_INPUT_STMPE811),y)
|
|||||||
CSRCS += stm32_stmpe811.c
|
CSRCS += stm32_stmpe811.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_SENSORS_QENCODER),y)
|
|
||||||
CSRCS += stm32_qencoder.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
DEPPATH += --dep-path board
|
DEPPATH += --dep-path board
|
||||||
VPATH += :board
|
VPATH += :board
|
||||||
CFLAGS += $(shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board)
|
CFLAGS += $(shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board)
|
||||||
|
|||||||
@@ -115,10 +115,6 @@ ifeq ($(CONFIG_LCD_PCD8544),y)
|
|||||||
CSRCS += stm32_pcd8544.c
|
CSRCS += stm32_pcd8544.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_SENSORS_QENCODER),y)
|
|
||||||
CSRCS += stm32_qencoder.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_USBDEV),y)
|
ifeq ($(CONFIG_USBDEV),y)
|
||||||
CSRCS += stm32_usbdev.c
|
CSRCS += stm32_usbdev.c
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -129,6 +129,10 @@
|
|||||||
#include "stm32_zerocross.h"
|
#include "stm32_zerocross.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_SENSORS_QENCODER
|
||||||
|
#include "board_qencoder.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -402,7 +406,7 @@ int stm32_bringup(void)
|
|||||||
#ifdef CONFIG_SENSORS_QENCODER
|
#ifdef CONFIG_SENSORS_QENCODER
|
||||||
/* Initialize and register the qencoder driver */
|
/* Initialize and register the qencoder driver */
|
||||||
|
|
||||||
ret = stm32_qencoder_initialize("/dev/qe0",
|
ret = board_qencoder_initialize(0,
|
||||||
CONFIG_STM32F103MINIMUM_QETIMER);
|
CONFIG_STM32F103MINIMUM_QETIMER);
|
||||||
if (ret != OK)
|
if (ret != OK)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -292,18 +292,6 @@ int stm32_max6675initialize(FAR const char *devpath);
|
|||||||
|
|
||||||
int stm32_w25initialize(int minor);
|
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
|
* Name: stm32_rgbled_setup
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -60,10 +60,6 @@ ifeq ($(CONFIG_PWM),y)
|
|||||||
CSRCS += stm32_pwm.c
|
CSRCS += stm32_pwm.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_SENSORS_QENCODER),y)
|
|
||||||
CSRCS += stm32_qencoder.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
DEPPATH += --dep-path board
|
DEPPATH += --dep-path board
|
||||||
VPATH += :board
|
VPATH += :board
|
||||||
CFLAGS += $(shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board)
|
CFLAGS += $(shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board)
|
||||||
|
|||||||
@@ -53,6 +53,10 @@
|
|||||||
#include "stm32.h"
|
#include "stm32.h"
|
||||||
#include "stm32f3discovery.h"
|
#include "stm32f3discovery.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_SENSORS_QENCODER
|
||||||
|
#include "board_qencoder.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -129,7 +133,7 @@ int stm32_bringup(void)
|
|||||||
#ifdef CONFIG_SENSORS_QENCODER
|
#ifdef CONFIG_SENSORS_QENCODER
|
||||||
/* Initialize and register the qencoder driver */
|
/* 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)
|
if (ret != OK)
|
||||||
{
|
{
|
||||||
syslog(LOG_ERR,
|
syslog(LOG_ERR,
|
||||||
|
|||||||
@@ -1,82 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* boards/arm/stm32/stm32f3discovery/src/stm32_qencoder.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved.
|
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
*
|
|
||||||
* 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/sensors/qencoder.h>
|
|
||||||
#include <arch/board/board.h>
|
|
||||||
|
|
||||||
#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 */
|
|
||||||
@@ -193,17 +193,5 @@ void weak_function stm32_usbinitialize(void);
|
|||||||
int stm32_pwm_setup(void);
|
int stm32_pwm_setup(void);
|
||||||
#endif
|
#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 /* __ASSEMBLY__ */
|
||||||
#endif /* __BOARDS_ARM_STM32_STM32F3DISCOVERY_SRC_STM32F3DISCOVERY_H */
|
#endif /* __BOARDS_ARM_STM32_STM32F3DISCOVERY_SRC_STM32F3DISCOVERY_H */
|
||||||
|
|||||||
@@ -129,10 +129,6 @@ ifeq ($(CONFIG_PWM),y)
|
|||||||
CSRCS += stm32_pwm.c
|
CSRCS += stm32_pwm.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_SENSORS_QENCODER),y)
|
|
||||||
CSRCS += stm32_qencoder.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_SENSORS_XEN1210),y)
|
ifeq ($(CONFIG_SENSORS_XEN1210),y)
|
||||||
CSRCS += stm32_xen1210.c
|
CSRCS += stm32_xen1210.c
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -98,6 +98,10 @@
|
|||||||
#include "stm32_zerocross.h"
|
#include "stm32_zerocross.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_SENSORS_QENCODER
|
||||||
|
#include "board_qencoder.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -345,7 +349,7 @@ int stm32_bringup(void)
|
|||||||
#ifdef CONFIG_SENSORS_QENCODER
|
#ifdef CONFIG_SENSORS_QENCODER
|
||||||
/* Initialize and register the qencoder driver */
|
/* 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)
|
if (ret != OK)
|
||||||
{
|
{
|
||||||
syslog(LOG_ERR,
|
syslog(LOG_ERR,
|
||||||
|
|||||||
@@ -1,80 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* boards/arm/stm32/stm32f4discovery/src/stm32_qencoder.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 2012, 2016 Gregory Nutt. All rights reserved.
|
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
*
|
|
||||||
* 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/sensors/qencoder.h>
|
|
||||||
#include <arch/board/board.h>
|
|
||||||
|
|
||||||
#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;
|
|
||||||
}
|
|
||||||
@@ -686,18 +686,6 @@ int stm32_sdio_initialize(void);
|
|||||||
void weak_function stm32_netinitialize(void);
|
void weak_function stm32_netinitialize(void);
|
||||||
#endif
|
#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
|
* Name: stm32_zerocross_initialize
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -56,10 +56,6 @@ ifeq ($(CONFIG_PWM),y)
|
|||||||
CSRCS += stm32_pwm.c
|
CSRCS += stm32_pwm.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_SENSORS_QENCODER),y)
|
|
||||||
CSRCS += stm32_qencoder.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_LIB_BOARDCTL),y)
|
ifeq ($(CONFIG_LIB_BOARDCTL),y)
|
||||||
CSRCS += stm32_appinit.c
|
CSRCS += stm32_appinit.c
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -48,6 +48,10 @@
|
|||||||
|
|
||||||
#include "stm32ldiscovery.h"
|
#include "stm32ldiscovery.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_SENSORS_QENCODER
|
||||||
|
#include "board_qencoder.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -104,7 +108,7 @@ int stm32_bringup(void)
|
|||||||
#ifdef CONFIG_SENSORS_QENCODER
|
#ifdef CONFIG_SENSORS_QENCODER
|
||||||
/* Initialize and register the qencoder driver */
|
/* 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)
|
if (ret != OK)
|
||||||
{
|
{
|
||||||
syslog(LOG_ERR,
|
syslog(LOG_ERR,
|
||||||
|
|||||||
@@ -1,82 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* boards/arm/stm32/stm32ldiscovery/src/up_qencoder.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved.
|
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
*
|
|
||||||
* 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/sensors/qencoder.h>
|
|
||||||
#include <arch/board/board.h>
|
|
||||||
|
|
||||||
#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 */
|
|
||||||
@@ -277,17 +277,5 @@ void weak_function stm32_spidev_initialize(void);
|
|||||||
int stm32_pwm_setup(void);
|
int stm32_pwm_setup(void);
|
||||||
#endif
|
#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 /* __ASSEMBLY__ */
|
||||||
#endif /* __BOARDS_ARM_STM32_STM32F3DISCOVERY_SRC_STM32F3DISCOVERY_H */
|
#endif /* __BOARDS_ARM_STM32_STM32F3DISCOVERY_SRC_STM32F3DISCOVERY_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user