mirror of
https://github.com/apache/nuttx.git
synced 2026-05-09 23:12:17 +08:00
boards/nrf52840-dk: add qencoder example
add qencoder support and enable qe example for jumbo config Signed-off-by: raiden00pl <raiden00@railab.me>
This commit is contained in:
@@ -23,10 +23,15 @@ CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARCH_STDARG_H=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=5500
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEBUG_FULLOPT=y
|
||||
CONFIG_DEBUG_SYMBOLS=y
|
||||
CONFIG_EXAMPLES_ADC=y
|
||||
CONFIG_EXAMPLES_ADC_NSAMPLES=4
|
||||
CONFIG_EXAMPLES_ADC_SWTRIG=y
|
||||
CONFIG_EXAMPLES_PWM=y
|
||||
CONFIG_EXAMPLES_QENCODER=y
|
||||
CONFIG_EXAMPLES_QENCODER_HAVE_MAXPOS=y
|
||||
CONFIG_EXAMPLES_QENCODER_MAXPOS=32
|
||||
CONFIG_EXAMPLES_TIMER=y
|
||||
CONFIG_EXAMPLES_WATCHDOG=y
|
||||
CONFIG_FAT_LCNAMES=y
|
||||
@@ -44,6 +49,7 @@ CONFIG_NRF52_PWM0_CH1=y
|
||||
CONFIG_NRF52_PWM0_CH2=y
|
||||
CONFIG_NRF52_PWM0_CH3=y
|
||||
CONFIG_NRF52_PWM_MULTICHAN=y
|
||||
CONFIG_NRF52_QDEC0=y
|
||||
CONFIG_NRF52_QSPI=y
|
||||
CONFIG_NRF52_SAADC=y
|
||||
CONFIG_NRF52_TIMER2=y
|
||||
@@ -62,6 +68,8 @@ CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SENSORS=y
|
||||
CONFIG_SENSORS_QENCODER=y
|
||||
CONFIG_START_DAY=26
|
||||
CONFIG_START_MONTH=3
|
||||
CONFIG_SYMTAB_ORDEREDBYNAME=y
|
||||
|
||||
@@ -185,4 +185,9 @@
|
||||
#define NRF52_QSPI0_IO2_PIN (GPIO_OUTPUT | GPIO_PORT0 | GPIO_PIN(22))
|
||||
#define NRF52_QSPI0_IO3_PIN (GPIO_OUTPUT | GPIO_PORT0 | GPIO_PIN(23))
|
||||
|
||||
/* QDEC Pins ****************************************************************/
|
||||
|
||||
#define BOARD_QDEC0_A_PIN (GPIO_INPUT | GPIO_PORT0 | GPIO_PIN(30))
|
||||
#define BOARD_QDEC0_B_PIN (GPIO_INPUT | GPIO_PORT0 | GPIO_PIN(31))
|
||||
|
||||
#endif /* __BOARDS_ARM_NRF52_NRF52840_DK_INCLUDE_BOARD_H */
|
||||
|
||||
@@ -84,6 +84,10 @@ if(CONFIG_NRF52_QSPI)
|
||||
list(APPEND SRCS nrf52_mx25.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_NRF52_QDEC)
|
||||
list(APPEND SRCS nrf52_qencoder.c)
|
||||
endif()
|
||||
|
||||
target_sources(board PRIVATE ${SRCS})
|
||||
|
||||
if(CONFIG_ARCH_BOARD_COMMON)
|
||||
|
||||
@@ -86,6 +86,10 @@ ifeq ($(CONFIG_NRF52_QSPI),y)
|
||||
CSRCS += nrf52_mx25.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NRF52_QDEC),y)
|
||||
CSRCS += nrf52_qencoder.c
|
||||
endif
|
||||
|
||||
DEPPATH += --dep-path board
|
||||
VPATH += :board
|
||||
CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board
|
||||
|
||||
@@ -215,5 +215,17 @@ int nrf52_mx25_initialize(void);
|
||||
int nrf52_gpioleds_initialize(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nrf52_qencoder_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize quadrature encoder driver.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SENSORS_QENCODER
|
||||
int nrf52_qencoder_initialize(int devno);
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __BOARDS_ARM_NRF52_NRF52840_DK_SRC_NRF52840_DK_H */
|
||||
|
||||
@@ -333,6 +333,14 @@ int nrf52_bringup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NRF52_QDEC0
|
||||
ret = nrf52_qencoder_initialize(0);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to initialize qencoder: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
UNUSED(ret);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/nrf52/nrf52840-dk/src/nrf52_qencoder.c
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/sensors/qencoder.h>
|
||||
|
||||
#include "nrf52_qdec.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static const struct nrf52_qeconfig_s g_qe0_config =
|
||||
{
|
||||
.sample_period = 0,
|
||||
.report_period = 0,
|
||||
.enable_debounce = false,
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int nrf52_qencoder_initialize(int devno)
|
||||
{
|
||||
struct qe_lowerhalf_s *lower;
|
||||
char devpath[12];
|
||||
int ret;
|
||||
|
||||
sninfo("Initializing /dev/qe%d\n", devno);
|
||||
|
||||
lower = nrf52_qeinitialize(devno, &g_qe0_config);
|
||||
if (lower == NULL)
|
||||
{
|
||||
snerr("ERROR: nrf52_qeinitialize failed\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
snprintf(devpath, sizeof(devpath), "/dev/qe%d", devno);
|
||||
|
||||
ret = qe_register(devpath, lower);
|
||||
if (ret < 0)
|
||||
{
|
||||
snerr("ERROR: qe_register failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
Reference in New Issue
Block a user