From f5df946676bb65094def8562f877ace2df77fee4 Mon Sep 17 00:00:00 2001 From: Roberto Bucher Date: Fri, 2 Aug 2024 09:43:40 +0200 Subject: [PATCH] Additional encoder for F7 and added functions for TimerHook for F745 and H745 and H743 --- .../nucleo-144/configs/f746-pysim/defconfig | 2 ++ boards/arm/stm32f7/nucleo-144/include/board.h | 3 +++ .../stm32f7/nucleo-144/src/stm32_bringup.c | 26 +++++++++++++++++++ .../nucleo-h743zi2/src/stm32_bringup.c | 14 ++++++++++ .../stm32h7/nucleo-h745zi/src/stm32_bringup.c | 14 ++++++++++ 5 files changed, 59 insertions(+) diff --git a/boards/arm/stm32f7/nucleo-144/configs/f746-pysim/defconfig b/boards/arm/stm32f7/nucleo-144/configs/f746-pysim/defconfig index 7998b3d65c..0c570032f8 100644 --- a/boards/arm/stm32f7/nucleo-144/configs/f746-pysim/defconfig +++ b/boards/arm/stm32f7/nucleo-144/configs/f746-pysim/defconfig @@ -134,6 +134,8 @@ CONFIG_STM32F7_TIM3=y CONFIG_STM32F7_TIM3_QE=y CONFIG_STM32F7_TIM4=y CONFIG_STM32F7_TIM4_QE=y +CONFIG_STM32F7_TIM8=y +CONFIG_STM32F7_TIM8_QE=y CONFIG_STM32F7_USART_BREAKS=y CONFIG_SYSTEM_DHCPC_RENEW=y CONFIG_SYSTEM_NSH=y diff --git a/boards/arm/stm32f7/nucleo-144/include/board.h b/boards/arm/stm32f7/nucleo-144/include/board.h index 4f6ee4f737..ec70ca8ce9 100644 --- a/boards/arm/stm32f7/nucleo-144/include/board.h +++ b/boards/arm/stm32f7/nucleo-144/include/board.h @@ -367,6 +367,9 @@ #define GPIO_TIM4_CH1IN (GPIO_TIM4_CH1IN_2|GPIO_SPEED_50MHz) #define GPIO_TIM4_CH2IN (GPIO_TIM4_CH2IN_2|GPIO_SPEED_50MHz) +#define GPIO_TIM8_CH1IN (GPIO_TIM8_CH1IN_1|GPIO_SPEED_50MHz) +#define GPIO_TIM8_CH2IN (GPIO_TIM8_CH2IN_1|GPIO_SPEED_50MHz) + /* PWM * Use Timer 1 or 3 */ diff --git a/boards/arm/stm32f7/nucleo-144/src/stm32_bringup.c b/boards/arm/stm32f7/nucleo-144/src/stm32_bringup.c index e51b91bf63..f0803f30e9 100644 --- a/boards/arm/stm32f7/nucleo-144/src/stm32_bringup.c +++ b/boards/arm/stm32f7/nucleo-144/src/stm32_bringup.c @@ -42,6 +42,10 @@ #include "stm32_romfs.h" #endif +#ifdef CONFIG_SYSTEMTICK_HOOK +#include +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -209,6 +213,18 @@ int stm32_bringup(void) } #endif +#ifdef CONFIG_STM32F7_TIM8_QE + snprintf(buf, sizeof(buf), "/dev/qe4"); + ret = stm32_qencoder_initialize(buf, 8); + if (ret < 0) + { + syslog(LOG_ERR, + "ERROR: Failed to register the qencoder: %d\n", + ret); + return ret; + } +#endif + #endif #ifdef CONFIG_STM32F7_CAN_CHARDRIVER @@ -265,3 +281,13 @@ int stm32_bringup(void) UNUSED(ret); return OK; } + +#ifdef CONFIG_SYSTEMTICK_HOOK + +sem_t g_waitsem; + +void board_timerhook(void) +{ + (void)sem_post(&g_waitsem); +} +#endif diff --git a/boards/arm/stm32h7/nucleo-h743zi2/src/stm32_bringup.c b/boards/arm/stm32h7/nucleo-h743zi2/src/stm32_bringup.c index 20c1bed08d..7ed413b7df 100644 --- a/boards/arm/stm32h7/nucleo-h743zi2/src/stm32_bringup.c +++ b/boards/arm/stm32h7/nucleo-h743zi2/src/stm32_bringup.c @@ -41,6 +41,10 @@ #include "stm32_fdcan_sock.h" #endif +#ifdef CONFIG_SYSTEMTICK_HOOK +#include +#endif + #include "nucleo-h743zi2.h" /**************************************************************************** @@ -258,3 +262,13 @@ int stm32_bringup(void) return OK; } + +#ifdef CONFIG_SYSTEMTICK_HOOK + +sem_t g_waitsem; + +void board_timerhook(void) +{ + (void)sem_post(&g_waitsem); +} +#endif diff --git a/boards/arm/stm32h7/nucleo-h745zi/src/stm32_bringup.c b/boards/arm/stm32h7/nucleo-h745zi/src/stm32_bringup.c index 65b816f5d7..f7295e0be4 100644 --- a/boards/arm/stm32h7/nucleo-h745zi/src/stm32_bringup.c +++ b/boards/arm/stm32h7/nucleo-h745zi/src/stm32_bringup.c @@ -39,6 +39,10 @@ # include #endif +#ifdef CONFIG_SYSTEMTICK_HOOK +#include +#endif + #include "nucleo-h745zi.h" /**************************************************************************** @@ -227,3 +231,13 @@ int stm32_bringup(void) return OK; } + +#ifdef CONFIG_SYSTEMTICK_HOOK + +sem_t g_waitsem; + +void board_timerhook(void) +{ + (void)sem_post(&g_waitsem); +} +#endif