boards/stm32h7: Add button support to nucleo-h743zi2

This patch adds support for the user button on nuclo-h743zi2 board
(and nucleo-h753zi2 which is also a MB1364 board design) and enables
button support and example in nucleo-h743zi2:jumbo configuration selector.

Signed-off-by: Peter Barada <peter.barada@gmail.com>
This commit is contained in:
Peter Barada
2026-02-20 15:06:55 -05:00
committed by Mateusz Szafoni
parent 966be68259
commit c4d6b728a0
8 changed files with 396 additions and 83 deletions
@@ -11,10 +11,12 @@
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="nucleo-h743zi2"
CONFIG_ARCH_BOARD_NUCLEO_H743ZI2=y
CONFIG_ARCH_BUTTONS=y
CONFIG_ARCH_CHIP="stm32h7"
CONFIG_ARCH_CHIP_STM32H743ZI=y
CONFIG_ARCH_CHIP_STM32H7=y
CONFIG_ARCH_CHIP_STM32H7_CORTEXM7=y
CONFIG_ARCH_IRQBUTTONS=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARMV7M_DCACHE=y
CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y
@@ -32,6 +34,10 @@ CONFIG_DEBUG_USB_WARN=y
CONFIG_DEFAULT_TASK_STACKSIZE=4096
CONFIG_DHCPC_RENEW_STACKSIZE=2048
CONFIG_ETH0_PHY_LAN8742A=y
CONFIG_EXAMPLES_BUTTONS=y
CONFIG_EXAMPLES_BUTTONS_NAME0="B1"
CONFIG_EXAMPLES_BUTTONS_NAMES=y
CONFIG_EXAMPLES_BUTTONS_QTD=1
CONFIG_EXAMPLES_HIDKBD=y
CONFIG_EXAMPLES_TOUCHSCREEN=y
CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH="/dev/mouse0"
@@ -44,6 +50,8 @@ CONFIG_FS_PROCFS_REGISTER=y
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INPUT_BUTTONS=y
CONFIG_INPUT_BUTTONS_LOWER=y
CONFIG_INTELHEX_BINARY=y
CONFIG_LIBM=y
CONFIG_LINE_MAX=64
@@ -56,6 +56,10 @@ if(CONFIG_BOARDCTL_RESET)
list(APPEND SRCS stm32_reset.c)
endif()
if(CONFIG_ARCH_BUTTONS)
list(APPEND SRCS stm32_buttons.c)
endif()
target_sources(board PRIVATE ${SRCS})
set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/flash.ld")
@@ -64,6 +68,5 @@ if(NOT CONFIG_BUILD_FLAT)
add_subdirectory(${NUTTX_BOARD_DIR}/kernel)
set_property(
GLOBAL PROPERTY LD_SCRIPT_USER ${NUTTX_BOARD_DIR}/scripts/memory.ld
${NUTTX_BOARD_DIR}/scripts/user-space.ld)
${NUTTX_BOARD_DIR}/scripts/user-space.ld)
endif()
@@ -34,6 +34,10 @@ else
CSRCS += stm32_userleds.c
endif
ifeq ($(CONFIG_ARCH_BUTTONS),y)
CSRCS += stm32_buttons.c
endif
ifeq ($(CONFIG_STM32H7_OTGFS),y)
CSRCS += stm32_usb.c
endif
@@ -88,6 +88,19 @@
#define GPIO_LED_ORANGE GPIO_LD2
#define GPIO_LED_RED GPIO_LD3
/* BUTTONS
*
* The Blue pushbutton B1, labeled "User", is connected to GPIO PC13.
* A high value will be sensed when the button is depressed.
* Note:
* 1) That the EXTI is included in the definition to enable an interrupt
* on this IO.
* 2) The following definitions assume the default Solder Bridges are
* installed.
*/
#define GPIO_BTN_USER (GPIO_INPUT | GPIO_FLOAT | GPIO_EXTI | GPIO_PORTC | GPIO_PIN13)
#define GPIO_OTGFS_VBUS (GPIO_INPUT|GPIO_FLOAT|GPIO_SPEED_100MHz| \
GPIO_OPENDRAIN|GPIO_PORTA|GPIO_PIN9)
@@ -49,6 +49,10 @@
#include "nucleo-h743zi2.h"
#ifdef CONFIG_INPUT_BUTTONS
# include <nuttx/input/buttons.h>
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
@@ -157,6 +161,16 @@ int stm32_bringup(void)
}
#endif
#if defined(CONFIG_INPUT_BUTTONS_LOWER)
/* Register the BUTTON driver */
ret = btn_lower_initialize("/dev/buttons");
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: btn_lower_initialize() failed: %d\n", ret);
}
#endif /* CONFIG_INPUT_BUTTONS */
#ifdef HAVE_USBHOST
/* Initialize USB host operation. stm32_usbhost_initialize()
* starts a thread will monitor for USB connection and
@@ -0,0 +1,107 @@
/****************************************************************************
* boards/arm/stm32h7/nucleo-h743zi2/src/stm32_buttons.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 <stddef.h>
#include <errno.h>
#include <nuttx/irq.h>
#include <nuttx/board.h>
#include "stm32_gpio.h"
#include "nucleo-h743zi2.h"
#include <arch/board/board.h>
#ifdef CONFIG_ARCH_BUTTONS
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_button_initialize
*
* Description:
* board_button_initialize() must be called to initialize button resources.
* After that, board_buttons() may be called to collect the current state
* of all buttons or board_button_irq() may be called to register button
* interrupt handlers.
*
****************************************************************************/
uint32_t board_button_initialize(void)
{
stm32_configgpio(GPIO_BTN_USER);
return NUM_BUTTONS;
}
/****************************************************************************
* Name: board_buttons
****************************************************************************/
uint32_t board_buttons(void)
{
return stm32_gpioread(GPIO_BTN_USER) ? 1 : 0;
}
/****************************************************************************
* Button support.
*
* Description:
* board_button_initialize() must be called to initialize button resources.
* After that, board_buttons() may be called to collect the current state
* of all buttons or board_button_irq() may be called to register button
* interrupt handlers.
*
* After board_button_initialize() has been called, board_buttons() may be
* called to collect the state of all buttons. board_buttons() returns a
* 32-bit bit set with each bit associated with a button. See the
* BUTTON_*_BIT definitions in board.h for the meaning of each bit.
*
* board_button_irq() may be called to register an interrupt handler that
* will be called when a button is depressed or released. The ID value is
* a button enumeration value that uniquely identifies a button resource.
* See the BUTTON_* definitions in board.h for the meaning of enumeration
* value.
*
****************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, void *arg)
{
int ret = -EINVAL;
if (id == BUTTON_USER)
{
ret = stm32_gpiosetevent(GPIO_BTN_USER, true, true, true,
irqhandler, arg);
}
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */