stm32h7/linum-stm32h753bi: add support to qencoder
Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
This commit is contained in:
parent
48cf91a7be
commit
738a30a421
@ -754,4 +754,18 @@ This configuration is focused on network testing using the ethernet periferal::
|
|||||||
56 bytes from 142.251.129.110: icmp_seq=8 time=0.0 ms
|
56 bytes from 142.251.129.110: icmp_seq=8 time=0.0 ms
|
||||||
56 bytes from 142.251.129.110: icmp_seq=9 time=0.0 ms
|
56 bytes from 142.251.129.110: icmp_seq=9 time=0.0 ms
|
||||||
10 packets transmitted, 10 received, 0% packet loss, time 10100 ms
|
10 packets transmitted, 10 received, 0% packet loss, time 10100 ms
|
||||||
rtt min/avg/max/mdev = 0.000/1.000/10.000/3.000 ms
|
rtt min/avg/max/mdev = 0.000/1.000/10.000/3.000 ms
|
||||||
|
|
||||||
|
qencoder
|
||||||
|
--------
|
||||||
|
|
||||||
|
Configures and enables TIM5 on CH1(PA0) and CH2(PH11) to handle Quadrature Encoder:
|
||||||
|
|
||||||
|
nsh> qe
|
||||||
|
qe_main: Hardware initialized. Opening the encoder device: /dev/qe0
|
||||||
|
qe_main: Number of samples: 0
|
||||||
|
qe_main: 1. 1
|
||||||
|
qe_main: 2. 2
|
||||||
|
qe_main: 3. 3
|
||||||
|
qe_main: 4. 2
|
||||||
|
qe_main: 5. 1
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
#
|
||||||
|
# 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_STM32H7_USE_LEGACY_PINMAP is not set
|
||||||
|
CONFIG_ARCH="arm"
|
||||||
|
CONFIG_ARCH_BOARD="linum-stm32h753bi"
|
||||||
|
CONFIG_ARCH_BOARD_LINUM_STM32H753BI=y
|
||||||
|
CONFIG_ARCH_CHIP="stm32h7"
|
||||||
|
CONFIG_ARCH_CHIP_STM32H753BI=y
|
||||||
|
CONFIG_ARCH_CHIP_STM32H7=y
|
||||||
|
CONFIG_ARCH_CHIP_STM32H7_CORTEXM7=y
|
||||||
|
CONFIG_ARCH_STACKDUMP=y
|
||||||
|
CONFIG_ARMV7M_DCACHE=y
|
||||||
|
CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y
|
||||||
|
CONFIG_ARMV7M_DTCM=y
|
||||||
|
CONFIG_ARMV7M_ICACHE=y
|
||||||
|
CONFIG_BOARD_LOOPSPERMSEC=43103
|
||||||
|
CONFIG_BUILTIN=y
|
||||||
|
CONFIG_DEBUG_FEATURES=y
|
||||||
|
CONFIG_DEBUG_SYMBOLS=y
|
||||||
|
CONFIG_EXAMPLES_ALARM=y
|
||||||
|
CONFIG_EXAMPLES_QENCODER=y
|
||||||
|
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||||
|
CONFIG_INTELHEX_BINARY=y
|
||||||
|
CONFIG_LIBM=y
|
||||||
|
CONFIG_MM_REGIONS=4
|
||||||
|
CONFIG_NSH_ARCHINIT=y
|
||||||
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
|
CONFIG_NSH_FILEIOSIZE=512
|
||||||
|
CONFIG_NSH_LINELEN=64
|
||||||
|
CONFIG_NSH_READLINE=y
|
||||||
|
CONFIG_PREALLOC_TIMERS=4
|
||||||
|
CONFIG_RAM_SIZE=245760
|
||||||
|
CONFIG_RAM_START=0x20010000
|
||||||
|
CONFIG_RAW_BINARY=y
|
||||||
|
CONFIG_RR_INTERVAL=200
|
||||||
|
CONFIG_RTC_ALARM=y
|
||||||
|
CONFIG_RTC_DATETIME=y
|
||||||
|
CONFIG_RTC_DRIVER=y
|
||||||
|
CONFIG_SCHED_WAITPID=y
|
||||||
|
CONFIG_SENSORS=y
|
||||||
|
CONFIG_SENSORS_QENCODER=y
|
||||||
|
CONFIG_START_DAY=6
|
||||||
|
CONFIG_START_MONTH=12
|
||||||
|
CONFIG_START_YEAR=2011
|
||||||
|
CONFIG_STM32H7_PWR=y
|
||||||
|
CONFIG_STM32H7_RTC=y
|
||||||
|
CONFIG_STM32H7_TIM5=y
|
||||||
|
CONFIG_STM32H7_TIM5_QE=y
|
||||||
|
CONFIG_STM32H7_USART1=y
|
||||||
|
CONFIG_SYSTEM_NSH=y
|
||||||
|
CONFIG_TASK_NAME_SIZE=0
|
||||||
|
CONFIG_USART1_SERIAL_CONSOLE=y
|
@ -439,6 +439,10 @@
|
|||||||
#define GPIO_ETH_RMII_TXD1 (GPIO_ETH_RMII_TXD1_3|GPIO_SPEED_100MHz) /* PG14 */
|
#define GPIO_ETH_RMII_TXD1 (GPIO_ETH_RMII_TXD1_3|GPIO_SPEED_100MHz) /* PG14 */
|
||||||
#define GPIO_ETH_RMII_TX_EN (GPIO_ETH_RMII_TX_EN_2|GPIO_SPEED_100MHz) /* PG11 */
|
#define GPIO_ETH_RMII_TX_EN (GPIO_ETH_RMII_TX_EN_2|GPIO_SPEED_100MHz) /* PG11 */
|
||||||
|
|
||||||
|
/* QEncoder - TIM5: CH1 and CH2 */
|
||||||
|
#define GPIO_TIM5_CH1IN GPIO_TIM5_CH1IN_1 /* PA0 */
|
||||||
|
#define GPIO_TIM5_CH2IN GPIO_TIM5_CH2IN_2 /* PH11 */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Data
|
* Public Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
@ -60,6 +60,10 @@ if(CONFIG_USBMSC)
|
|||||||
list(APPEND SRCS stm32_usbmsc.c)
|
list(APPEND SRCS stm32_usbmsc.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(CONFIG_SENSORS_QENCODER)
|
||||||
|
list(APPEND SRCS stm32_qencoder.c)
|
||||||
|
endif()
|
||||||
|
|
||||||
target_sources(board PRIVATE ${SRCS})
|
target_sources(board PRIVATE ${SRCS})
|
||||||
|
|
||||||
set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/flash.ld")
|
set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/flash.ld")
|
||||||
|
@ -58,6 +58,10 @@ ifeq ($(CONFIG_USBMSC),y)
|
|||||||
CSRCS += stm32_usbmsc.c
|
CSRCS += stm32_usbmsc.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_SENSORS_QENCODER),y)
|
||||||
|
CSRCS += stm32_qencoder.c
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_BOARDCTL),y)
|
ifeq ($(CONFIG_BOARDCTL),y)
|
||||||
CSRCS += stm32_appinitialize.c
|
CSRCS += stm32_appinitialize.c
|
||||||
endif
|
endif
|
||||||
|
@ -111,6 +111,13 @@
|
|||||||
#define GPIO_ETH_RESET (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_100MHz |\
|
#define GPIO_ETH_RESET (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_100MHz |\
|
||||||
GPIO_OUTPUT_CLEAR | GPIO_PORTI | GPIO_PIN4) /* PI4 */
|
GPIO_OUTPUT_CLEAR | GPIO_PORTI | GPIO_PIN4) /* PI4 */
|
||||||
|
|
||||||
|
/* Quadrature Encoder
|
||||||
|
*
|
||||||
|
* Use Timer 5 (TIM3) on channels 2 and 2 for QEncoder, using PB4 and PA7.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define LINUMSTM32H753BI_QETIMER 5
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -207,4 +214,14 @@ int stm32_pwm_setup(void);
|
|||||||
int stm32_w25qxxx_setup(void);
|
int stm32_w25qxxx_setup(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_qencoder_initialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize the quadrature encoder driver for the given timer
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int board_qencoder_initialize(int devno, int timerno);
|
||||||
|
|
||||||
#endif /* __BOARDS_ARM_STM32H7_LINUM_STM32H753BI_SRC_LINUM_STM32H753BI_H */
|
#endif /* __BOARDS_ARM_STM32H7_LINUM_STM32H753BI_SRC_LINUM_STM32H753BI_H */
|
||||||
|
@ -266,5 +266,18 @@ int stm32_bringup(void)
|
|||||||
usbdev_rndis_initialize(mac);
|
usbdev_rndis_initialize(mac);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_SENSORS_QENCODER)
|
||||||
|
/* Initialize and register the qencoder driver */
|
||||||
|
|
||||||
|
ret = board_qencoder_initialize(0, LINUMSTM32H753BI_QETIMER);
|
||||||
|
if (ret != OK)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR,
|
||||||
|
"ERROR: Failed to register the qencoder: %d\n",
|
||||||
|
ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
66
boards/arm/stm32h7/linum-stm32h753bi/src/stm32_qencoder.c
Normal file
66
boards/arm/stm32h7/linum-stm32h753bi/src/stm32_qencoder.c
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* boards/arm/stm32h7/linum-stm32h753bi/src/stm32_qencoder.c
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <debug.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <nuttx/sensors/qencoder.h>
|
||||||
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
|
#include "chip.h"
|
||||||
|
#include "arm_internal.h"
|
||||||
|
#include "stm32_qencoder.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_qencoder_initialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize the quadrature encoder driver for the given 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", timerno);
|
||||||
|
snprintf(devpath, 12, "/dev/qe%d", devno);
|
||||||
|
ret = stm32_qeinitialize(devpath, timerno);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
snerr("ERROR: stm32_qeinitialize failed: %d\n", ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user