mirror of
https://github.com/apache/nuttx.git
synced 2026-05-23 23:28:29 +08:00
add qencoder support and enable qe example for config Signed-off-by: raiden00pl <raiden00@railab.me>
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
#
|
||||
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||
#
|
||||
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||
# modifications.
|
||||
#
|
||||
# CONFIG_NSH_DISABLE_IFCONFIG is not set
|
||||
# CONFIG_NSH_DISABLE_PS is not set
|
||||
# CONFIG_STANDARD_SERIAL is not set
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="nrf5340-dk"
|
||||
CONFIG_ARCH_BOARD_NRF5340_DK=y
|
||||
CONFIG_ARCH_CHIP="nrf53"
|
||||
CONFIG_ARCH_CHIP_NRF5340=y
|
||||
CONFIG_ARCH_CHIP_NRF5340_CPUAPP=y
|
||||
CONFIG_ARCH_CHIP_NRF53=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARCH_STDARG_H=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=5500
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_EXAMPLES_QENCODER=y
|
||||
CONFIG_EXAMPLES_QENCODER_HAVE_MAXPOS=y
|
||||
CONFIG_EXAMPLES_QENCODER_MAXPOS=32
|
||||
CONFIG_EXPERIMENTAL=y
|
||||
CONFIG_FAT_LCNAMES=y
|
||||
CONFIG_FAT_LFN=y
|
||||
CONFIG_FS_FAT=y
|
||||
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||
CONFIG_LINE_MAX=64
|
||||
CONFIG_MM_REGIONS=2
|
||||
CONFIG_NRF53_QDEC0=y
|
||||
CONFIG_NRF53_UART0=y
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_RAM_SIZE=524288
|
||||
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
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_TASK_NAME_SIZE=0
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||
@@ -179,4 +179,9 @@
|
||||
#define NRF53_QSPI0_IO3_PIN (GPIO_MCUSEL_PERIP | GPIO_OUTPUT | \
|
||||
GPIO_PORT0 | GPIO_PIN(16))
|
||||
|
||||
/* QDEC Pins ****************************************************************/
|
||||
|
||||
#define BOARD_QDEC0_A_PIN (GPIO_MCUSEL_APP | GPIO_INPUT | GPIO_PORT0 | GPIO_PIN(25))
|
||||
#define BOARD_QDEC0_B_PIN (GPIO_MCUSEL_APP | GPIO_INPUT | GPIO_PORT0 | GPIO_PIN(26))
|
||||
|
||||
#endif /* __BOARDS_ARM_NRF53_NRF5340_DK_INCLUDE_BOARD_H */
|
||||
|
||||
@@ -64,6 +64,10 @@ if(CONFIG_NRF53_QSPI)
|
||||
list(APPEND SRCS nrf53_mx25.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_NRF53_QDEC)
|
||||
list(APPEND SRCS nrf53_qencoder.c)
|
||||
endif()
|
||||
|
||||
target_sources(board PRIVATE ${SRCS})
|
||||
|
||||
if(CONFIG_ARCH_BOARD_COMMON)
|
||||
|
||||
@@ -66,6 +66,10 @@ ifeq ($(CONFIG_NRF53_QSPI),y)
|
||||
CSRCS += nrf53_mx25.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NRF53_QDEC),y)
|
||||
CSRCS += nrf53_qencoder.c
|
||||
endif
|
||||
|
||||
DEPPATH += --dep-path board
|
||||
VPATH += :board
|
||||
CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board
|
||||
|
||||
@@ -164,5 +164,17 @@ int nrf53_mx25_initialize(void);
|
||||
int nrf53_gpio_initialize(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nrf53_qencoder_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize and register the qencoder driver
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NRF53_QDEC
|
||||
int nrf53_qencoder_initialize(int devno);
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __BOARDS_ARM_NRF53_NRF5340_DK_SRC_NRF5340_DK_H */
|
||||
|
||||
@@ -267,6 +267,14 @@ int nrf53_bringup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NRF53_QDEC0
|
||||
ret = nrf53_qencoder_initialize(0);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to initialize qencoder: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USBMONITOR
|
||||
/* Start the USB Monitor */
|
||||
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/nrf53/nrf5340-dk/src/nrf53_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 "nrf53_qdec.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static const struct nrf53_qeconfig_s g_qe0_config =
|
||||
{
|
||||
.sample_period = 0,
|
||||
.report_period = 0,
|
||||
.enable_debounce = false,
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int nrf53_qencoder_initialize(int devno)
|
||||
{
|
||||
struct qe_lowerhalf_s *lower;
|
||||
char devpath[12];
|
||||
int ret;
|
||||
|
||||
sninfo("Initializing /dev/qe%d\n", devno);
|
||||
|
||||
lower = nrf53_qeinitialize(devno, &g_qe0_config);
|
||||
if (lower == NULL)
|
||||
{
|
||||
snerr("ERROR: nrf53_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