This is an automated email from the ASF dual-hosted git repository.

simbit18 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 3455deb83c717283ae79cfc83f6fac38e3ebb123
Author: raiden00pl <[email protected]>
AuthorDate: Fri Aug 14 08:58:52 2026 +0200

    boards/stm32u0: add stm32u083c-dk support
    
    add stm32u083c-dk support
    
    Signed-off-by: raiden00pl <[email protected]>
    Assisted-by: Claude Code
---
 .../arm/stm32u0/boards/stm32u083c-dk/index.rst     |  66 ++++
 boards/Kconfig                                     |  12 +
 boards/arm/stm32u0/stm32u083c-dk/CMakeLists.txt    |  23 ++
 boards/arm/stm32u0/stm32u083c-dk/Kconfig           |   8 +
 .../stm32u0/stm32u083c-dk/configs/jumbo/defconfig  |  78 ++++
 .../stm32u0/stm32u083c-dk/configs/nsh/defconfig    |  43 +++
 boards/arm/stm32u0/stm32u083c-dk/include/board.h   | 195 ++++++++++
 boards/arm/stm32u0/stm32u083c-dk/scripts/Make.defs |  37 ++
 boards/arm/stm32u0/stm32u083c-dk/scripts/flash.ld  | 111 ++++++
 .../arm/stm32u0/stm32u083c-dk/src/CMakeLists.txt   |  40 +++
 boards/arm/stm32u0/stm32u083c-dk/src/Make.defs     |  42 +++
 boards/arm/stm32u0/stm32u083c-dk/src/stm32_adc.c   | 127 +++++++
 .../arm/stm32u0/stm32u083c-dk/src/stm32_autoleds.c |  82 +++++
 boards/arm/stm32u0/stm32u083c-dk/src/stm32_boot.c  |  83 +++++
 .../arm/stm32u0/stm32u083c-dk/src/stm32_bringup.c  | 138 ++++++++
 .../stm32u0/stm32u083c-dk/src/stm32_djoystick.c    | 394 +++++++++++++++++++++
 .../arm/stm32u0/stm32u083c-dk/src/stm32_userleds.c | 179 ++++++++++
 .../arm/stm32u0/stm32u083c-dk/src/stm32u083c-dk.h  | 109 ++++++
 18 files changed, 1767 insertions(+)

diff --git a/Documentation/platforms/arm/stm32u0/boards/stm32u083c-dk/index.rst 
b/Documentation/platforms/arm/stm32u0/boards/stm32u083c-dk/index.rst
new file mode 100644
index 00000000000..29e9e46b1df
--- /dev/null
+++ b/Documentation/platforms/arm/stm32u0/boards/stm32u083c-dk/index.rst
@@ -0,0 +1,66 @@
+================
+ST STM32U083C-DK
+================
+
+.. tags:: chip:stm32, chip:stm32u0, chip:stm32u083
+
+The STM32U083C-DK is a Discovery kit based on the STM32U083MC MCU.
+
+USB, LCD and touchkey (TSC) not supported yet.
+
+LEDs
+====
+
+The board has three user LEDs:
+
+- LD3 (green) connected to the I/O PC13
+- LD4 (blue) connected to the I/O PA5
+- LD5 (red) connected to the I/O PB2
+
+There are no GPIO user buttons on this board.  The touchkey is connected
+to the TSC.
+
+Joystick
+========
+
+The 4-direction joystick with selection is connected to a resistor ladder
+on PC2 (ADC1 IN2).  It is supported by the discrete joystick driver
+(``/dev/djoy0``) which decodes the ADC conversion result into joystick
+positions.  Joystick events are detected by polling the ADC from the low
+priority work queue.
+
+Serial Console
+==============
+
+At default USART2 connected to "Virtual COM Port" is used as serial console.
+
+Configurations
+==============
+
+nsh
+---
+
+Configures the NuttShell (nsh) located at apps/examples/nsh.  The
+Configuration enables the serial interfaces on USART2.  Support for
+builtin applications is disabled.
+
+jumbo
+-----
+
+This configuration enables many Apache NuttX features.  This is
+mostly to help provide additional code coverage in CI, but also
+allows for a users to see a wide range of features that are
+supported by the OS.
+
+Enabled features:
+
+- NSH with builtin applications
+
+- OS test (ostest)
+
+- joystick on PC2 (ADC1 IN2) with the discrete joystick driver and ADC
+  with DMA enabled
+
+- PWM on TIM1 CH1 (PA8, arduino D5)
+
+- IWDG and WWDG watchdogs
diff --git a/boards/Kconfig b/boards/Kconfig
index d05381e3843..d169832406c 100644
--- a/boards/Kconfig
+++ b/boards/Kconfig
@@ -3063,6 +3063,14 @@ config ARCH_BOARD_NUCLEO_U083RC
        ---help---
                STMicro NUCLEO U083RC board based on the STMicro STM32U083RC 
MCU.
 
+config ARCH_BOARD_STM32U083C_DK
+       bool "STMicro STM32U083C-DK board"
+       depends on ARCH_CHIP_STM32U083MC
+       select ARCH_HAVE_LEDS
+       ---help---
+               STMicro STM32U083C-DK Discovery kit based on the STMicro
+               STM32U083MC MCU.
+
 config ARCH_BOARD_STM32F3_DISCOVERY
        bool "STMicro STM32F3-Discovery board"
        depends on ARCH_CHIP_STM32F303VC
@@ -4070,6 +4078,7 @@ config ARCH_BOARD
        default "nucleo-c071rb"                if ARCH_BOARD_NUCLEO_C071RB
        default "nucleo-c092rc"                if ARCH_BOARD_NUCLEO_C092RC
        default "nucleo-u083rc"                if ARCH_BOARD_NUCLEO_U083RC
+       default "stm32u083c-dk"                if ARCH_BOARD_STM32U083C_DK
        default "stm32f103-minimum"            if ARCH_BOARD_STM32F103_MINIMUM
        default "stm32f411-minimum"            if ARCH_BOARD_STM32F411_MINIMUM
        default "stm3210e-eval"                if ARCH_BOARD_STM3210E_EVAL
@@ -4678,6 +4687,9 @@ endif
 if ARCH_BOARD_NUCLEO_U083RC
 source "boards/arm/stm32u0/nucleo-u083rc/Kconfig"
 endif
+if ARCH_BOARD_STM32U083C_DK
+source "boards/arm/stm32u0/stm32u083c-dk/Kconfig"
+endif
 if ARCH_BOARD_NUCLEO_F722ZE
 source "boards/arm/stm32f7/nucleo-f722ze/Kconfig"
 endif
diff --git a/boards/arm/stm32u0/stm32u083c-dk/CMakeLists.txt 
b/boards/arm/stm32u0/stm32u083c-dk/CMakeLists.txt
new file mode 100644
index 00000000000..f22c482b30f
--- /dev/null
+++ b/boards/arm/stm32u0/stm32u083c-dk/CMakeLists.txt
@@ -0,0 +1,23 @@
+# 
##############################################################################
+# boards/arm/stm32u0/stm32u083c-dk/CMakeLists.txt
+#
+# 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.
+#
+# 
##############################################################################
+
+add_subdirectory(src)
diff --git a/boards/arm/stm32u0/stm32u083c-dk/Kconfig 
b/boards/arm/stm32u0/stm32u083c-dk/Kconfig
new file mode 100644
index 00000000000..23edfd96014
--- /dev/null
+++ b/boards/arm/stm32u0/stm32u083c-dk/Kconfig
@@ -0,0 +1,8 @@
+#
+# For a description of the syntax of this configuration file,
+# see the file kconfig-language.txt in the NuttX tools repository.
+#
+
+if ARCH_BOARD_STM32U083C_DK
+
+endif
diff --git a/boards/arm/stm32u0/stm32u083c-dk/configs/jumbo/defconfig 
b/boards/arm/stm32u0/stm32u083c-dk/configs/jumbo/defconfig
new file mode 100644
index 00000000000..52272d556f8
--- /dev/null
+++ b/boards/arm/stm32u0/stm32u083c-dk/configs/jumbo/defconfig
@@ -0,0 +1,78 @@
+#
+# 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_ADC=y
+CONFIG_ANALOG=y
+CONFIG_ARCH="arm"
+CONFIG_ARCH_BOARD="stm32u083c-dk"
+CONFIG_ARCH_BOARD_COMMON=y
+CONFIG_ARCH_BOARD_STM32U083C_DK=y
+CONFIG_ARCH_CHIP="stm32u0"
+CONFIG_ARCH_CHIP_STM32=y
+CONFIG_ARCH_CHIP_STM32U083MC=y
+CONFIG_ARCH_CHIP_STM32U0=y
+CONFIG_ARCH_STACKDUMP=y
+CONFIG_BOARDCTL=y
+CONFIG_BOARD_LOOPSPERMSEC=4663
+CONFIG_BUILTIN=y
+CONFIG_DEBUG_FEATURES=y
+CONFIG_DEBUG_FULLOPT=y
+CONFIG_DEBUG_SYMBOLS=y
+CONFIG_DISABLE_ENVIRON=y
+CONFIG_DISABLE_MOUNTPOINT=y
+CONFIG_DISABLE_MQUEUE=y
+CONFIG_DISABLE_POSIX_TIMERS=y
+CONFIG_DISABLE_PSEUDOFS_OPERATIONS=y
+CONFIG_EXAMPLES_ADC=y
+CONFIG_EXAMPLES_ADC_GROUPSIZE=1
+CONFIG_EXAMPLES_ADC_SWTRIG=y
+CONFIG_EXAMPLES_DJOYSTICK=y
+CONFIG_EXAMPLES_HELLO=y
+CONFIG_EXAMPLES_PWM=y
+CONFIG_EXAMPLES_WATCHDOG=y
+CONFIG_INIT_ENTRYPOINT="nsh_main"
+CONFIG_INIT_STACKSIZE=1536
+CONFIG_INPUT=y
+CONFIG_INPUT_DJOYSTICK=y
+CONFIG_INTELHEX_BINARY=y
+CONFIG_LINE_MAX=64
+CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_FILEIOSIZE=64
+CONFIG_NSH_READLINE=y
+CONFIG_NUNGET_CHARS=0
+CONFIG_POSIX_SPAWN_DEFAULT_STACKSIZE=1536
+CONFIG_PTHREAD_MUTEX_UNSAFE=y
+CONFIG_PTHREAD_STACK_DEFAULT=1536
+CONFIG_PWM=y
+CONFIG_RAM_SIZE=40960
+CONFIG_RAM_START=0x20000000
+CONFIG_RAW_BINARY=y
+CONFIG_RR_INTERVAL=200
+CONFIG_SCHED_LPWORK=y
+CONFIG_SCHED_WAITPID=y
+CONFIG_SERIAL_TERMIOS=y
+CONFIG_START_DAY=19
+CONFIG_START_MONTH=5
+CONFIG_START_YEAR=2013
+CONFIG_STDIO_DISABLE_BUFFERING=y
+CONFIG_STM32_ADC1=y
+CONFIG_STM32_DMA1=y
+CONFIG_STM32_IWDG=y
+CONFIG_STM32_PWM_MULTICHAN=y
+CONFIG_STM32_PWR=y
+CONFIG_STM32_TIM1=y
+CONFIG_STM32_TIM1_CH1OUT=y
+CONFIG_STM32_TIM1_CHANNEL1=y
+CONFIG_STM32_TIM1_PWM=y
+CONFIG_STM32_USART2=y
+CONFIG_STM32_WWDG=y
+CONFIG_SYSTEM_NSH=y
+CONFIG_TASK_NAME_SIZE=0
+CONFIG_TESTING_OSTEST=y
+CONFIG_TESTING_OSTEST_STACKSIZE=3072
+CONFIG_USART2_SERIAL_CONSOLE=y
diff --git a/boards/arm/stm32u0/stm32u083c-dk/configs/nsh/defconfig 
b/boards/arm/stm32u0/stm32u083c-dk/configs/nsh/defconfig
new file mode 100644
index 00000000000..102ef0adaab
--- /dev/null
+++ b/boards/arm/stm32u0/stm32u083c-dk/configs/nsh/defconfig
@@ -0,0 +1,43 @@
+#
+# 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_ARCH="arm"
+CONFIG_ARCH_BOARD="stm32u083c-dk"
+CONFIG_ARCH_BOARD_STM32U083C_DK=y
+CONFIG_ARCH_CHIP="stm32u0"
+CONFIG_ARCH_CHIP_STM32=y
+CONFIG_ARCH_CHIP_STM32U083MC=y
+CONFIG_ARCH_CHIP_STM32U0=y
+CONFIG_ARCH_STACKDUMP=y
+CONFIG_BOARD_LOOPSPERMSEC=4663
+CONFIG_DEBUG_FULLOPT=y
+CONFIG_DEBUG_SYMBOLS=y
+CONFIG_INIT_ENTRYPOINT="nsh_main"
+CONFIG_INIT_STACKSIZE=1536
+CONFIG_INTELHEX_BINARY=y
+CONFIG_LINE_MAX=64
+CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
+CONFIG_NSH_FILEIOSIZE=64
+CONFIG_NSH_READLINE=y
+CONFIG_NUNGET_CHARS=0
+CONFIG_POSIX_SPAWN_DEFAULT_STACKSIZE=1536
+CONFIG_PTHREAD_MUTEX_UNSAFE=y
+CONFIG_PTHREAD_STACK_DEFAULT=1536
+CONFIG_RAM_SIZE=40960
+CONFIG_RAM_START=0x20000000
+CONFIG_RAW_BINARY=y
+CONFIG_RR_INTERVAL=200
+CONFIG_SCHED_WAITPID=y
+CONFIG_START_DAY=19
+CONFIG_START_MONTH=5
+CONFIG_START_YEAR=2013
+CONFIG_STDIO_DISABLE_BUFFERING=y
+CONFIG_STM32_PWR=y
+CONFIG_STM32_USART2=y
+CONFIG_SYSTEM_NSH=y
+CONFIG_TASK_NAME_SIZE=0
+CONFIG_USART2_SERIAL_CONSOLE=y
diff --git a/boards/arm/stm32u0/stm32u083c-dk/include/board.h 
b/boards/arm/stm32u0/stm32u083c-dk/include/board.h
new file mode 100644
index 00000000000..9b7fa3b23ef
--- /dev/null
+++ b/boards/arm/stm32u0/stm32u083c-dk/include/board.h
@@ -0,0 +1,195 @@
+/****************************************************************************
+ * boards/arm/stm32u0/stm32u083c-dk/include/board.h
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __BOARDS_ARM_STM32U0_STM32U083C_DK_INCLUDE_BOARD_H
+#define __BOARDS_ARM_STM32U0_STM32U083C_DK_INCLUDE_BOARD_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#ifndef __ASSEMBLY__
+#  include <stdint.h>
+#endif
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Clocking *****************************************************************/
+
+/* HSI - Internal 16 MHz RC Oscillator
+ * MSI - Internal multispeed RC Oscillator (100 kHz - 48 MHz)
+ * LSI - 32 kHz RC
+ * HSE - 8 MHz crystal (not fitted by default)
+ * LSE - 32.768 kHz
+ */
+
+#define STM32_BOARD_XTAL        8000000ul          /* 8MHz */
+
+#define STM32_HSI_FREQUENCY     16000000ul         /* 16MHz */
+#define STM32_LSI_FREQUENCY     32000              /* Between 30kHz and 60kHz 
*/
+#define STM32_HSE_FREQUENCY     STM32_BOARD_XTAL
+#define STM32_LSE_FREQUENCY     32768              /* X2 on board */
+
+/* PLL configuration
+ *
+ *   PLL source is HSI16
+ *   VCO input frequency  = 16 MHz / PLLM = 16 MHz (must be 2.66 - 16 MHz)
+ *   VCO output frequency = 16 MHz * PLLN = 112 MHz (must be 96 - 344 MHz)
+ *   PLLP output          = 112 MHz / PLLP = 56 MHz
+ *   PLLQ output          = 112 MHz / PLLQ = 56 MHz
+ *   PLLR output (SYSCLK) = 112 MHz / PLLR = 56 MHz
+ */
+
+#define STM32_PLLCFG_PLLSRC     RCC_PLLCFG_PLLSRC_HSI
+#define STM32_PLLCFG_PLLCFG     (RCC_PLLCFG_PLLPEN | RCC_PLLCFG_PLLREN)
+
+#define STM32_PLLCFG_PLLM       RCC_PLLCFG_PLLM(1)
+#define STM32_PLLCFG_PLLN       RCC_PLLCFG_PLLN(7)
+#define STM32_PLLCFG_PLLP       RCC_PLLCFG_PLLP(2)
+#define STM32_PLLCFG_PLLQ       RCC_PLLCFG_PLLQ(2)
+#define STM32_PLLCFG_PLLR       RCC_PLLCFG_PLLR(2)
+
+#define STM32_VCO_FREQUENCY     ((STM32_HSI_FREQUENCY / 1) * 7)
+#define STM32_PLLP_FREQUENCY    (STM32_VCO_FREQUENCY / 2)
+#define STM32_PLLQ_FREQUENCY    (STM32_VCO_FREQUENCY / 2)
+#define STM32_PLLR_FREQUENCY    (STM32_VCO_FREQUENCY / 2)
+
+/* Use the PLL as SYSCLK source (56 MHz) */
+
+#define STM32_SYSCLK_SW         RCC_CFGR_SW_PLL
+#define STM32_SYSCLK_SWS        RCC_CFGR_SWS_PLL
+#define STM32_SYSCLK_FREQUENCY  STM32_PLLR_FREQUENCY
+
+/* AHB clock (HCLK) is SYSCLK (56 MHz) */
+
+#define STM32_RCC_CFGR_HPRE     RCC_CFGR_HPRE_SYSCLK
+#define STM32_HCLK_FREQUENCY    STM32_SYSCLK_FREQUENCY
+
+/* APB clock (PCLK) is HCLK (56 MHz) */
+
+#define STM32_RCC_CFGR_PPRE1    RCC_CFGR_PPRE1_HCLK
+#define STM32_PCLK1_FREQUENCY   STM32_HCLK_FREQUENCY
+#define STM32_PCLK2_FREQUENCY   STM32_PCLK1_FREQUENCY
+
+/* All timers on PCLK x1 (56 MHz) */
+
+#define STM32_TIM1_CLKIN   STM32_PCLK1_FREQUENCY
+#define STM32_TIM2_CLKIN   STM32_PCLK1_FREQUENCY
+#define STM32_TIM3_CLKIN   STM32_PCLK1_FREQUENCY
+#define STM32_TIM6_CLKIN   STM32_PCLK1_FREQUENCY
+#define STM32_TIM7_CLKIN   STM32_PCLK1_FREQUENCY
+#define STM32_TIM15_CLKIN  STM32_PCLK1_FREQUENCY
+#define STM32_TIM16_CLKIN  STM32_PCLK1_FREQUENCY
+
+/* LED definitions **********************************************************/
+
+/* The STM32U083C-DK board has three user LEDs:
+ *
+ *   User LD3:   green LED connected to the I/O PC13.
+ *   User LD4:   blue LED connected to the I/O PA5.
+ *   User LD5:   red LED connected to the I/O PB2.
+ */
+
+/* LED index values for use with board_userled() */
+
+#define BOARD_LED1       0 /* User LD3 (green) */
+#define BOARD_LED2       1 /* User LD4 (blue) */
+#define BOARD_LED3       2 /* User LD5 (red) */
+#define BOARD_NLEDS      3
+
+/* LED bits for use with board_userled_all() */
+
+#define BOARD_LED1_BIT   (1 << BOARD_LED1)
+#define BOARD_LED2_BIT   (1 << BOARD_LED2)
+#define BOARD_LED3_BIT   (1 << BOARD_LED3)
+
+/* If CONFIG_ARCH_LEDs is defined, then NuttX will control the LED on the
+ * board. The following definitions describe how NuttX controls
+ * the LED:
+ *
+ *   SYMBOL              Meaning                  LED1 state
+ *   ------------------  -----------------------  ----------
+ *   LED_STARTED         NuttX has been started   OFF
+ *   LED_HEAPALLOCATE    Heap has been allocated  OFF
+ *   LED_IRQSENABLED     Interrupts enabled       OFF
+ *   LED_STACKCREATED    Idle stack created       ON
+ *   LED_INIRQ           In an interrupt          No change
+ *   LED_SIGNAL          In a signal handler      No change
+ *   LED_ASSERTION       An assertion failed      No change
+ *   LED_PANIC           The system has crashed   Blinking
+ *   LED_IDLE            STM32 is in sleep mode   Not used
+ */
+
+#define LED_STARTED      0
+#define LED_HEAPALLOCATE 0
+#define LED_IRQSENABLED  0
+#define LED_STACKCREATED 1
+#define LED_INIRQ        2
+#define LED_SIGNAL       2
+#define LED_ASSERTION    2
+#define LED_PANIC        1
+
+/* Button definitions *******************************************************/
+
+/* The STM32U083C-DK board has no GPIO user buttons.  The board provides
+ * a RESET push-button connected to NRST, a 4-direction joystick with
+ * selection connected to an ADC1 input (resistor ladder) and a touchkey
+ * connected to the TSC.
+ */
+
+/* Alternate function pin selections ****************************************/
+
+/* USART */
+
+/* By default the USART2 is connected to STLINK Virtual COM Port:
+ *   USART2_RX - PA3
+ *   USART2_TX - PA2
+ */
+
+#define GPIO_USART2_RX      (GPIO_USART2_RX_1|GPIO_SPEED_HIGH)    /* PA3 */
+#define GPIO_USART2_TX      (GPIO_USART2_TX_1|GPIO_SPEED_HIGH)    /* PA2 */
+
+/* USART3 at arduino D0/D1:
+ *   USART3_RX - PC5
+ *   USART3_TX - PC4
+ */
+
+#define GPIO_USART3_RX      (GPIO_USART3_RX_4|GPIO_SPEED_HIGH)    /* PC5 */
+#define GPIO_USART3_TX      (GPIO_USART3_TX_4|GPIO_SPEED_HIGH)    /* PC4 */
+
+/* PWM on TIM1:
+ *   TIM1_CH1 - PA8 (arduino D5)
+ */
+
+#define GPIO_TIM1_CH1OUT    (GPIO_TIM1_CH1OUT_1|GPIO_SPEED_HIGH)  /* PA8 */
+
+/* DMA channels *************************************************************/
+
+/* ADC */
+
+#define ADC1_DMA_CHAN DMAMAP_DMA1_ADC1     /* DMA1 */
+
+#endif /* __BOARDS_ARM_STM32U0_STM32U083C_DK_INCLUDE_BOARD_H */
diff --git a/boards/arm/stm32u0/stm32u083c-dk/scripts/Make.defs 
b/boards/arm/stm32u0/stm32u083c-dk/scripts/Make.defs
new file mode 100644
index 00000000000..2eca7ff578d
--- /dev/null
+++ b/boards/arm/stm32u0/stm32u083c-dk/scripts/Make.defs
@@ -0,0 +1,37 @@
+############################################################################
+# boards/arm/stm32u0/stm32u083c-dk/scripts/Make.defs
+#
+# 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.
+#
+############################################################################
+
+include $(TOPDIR)/.config
+include $(TOPDIR)/tools/Config.mk
+include $(TOPDIR)/arch/arm/src/armv6-m/Toolchain.defs
+
+LDSCRIPT = flash.ld
+ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
+
+CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) 
$(ARCHDEFINES) $(EXTRAFLAGS)
+CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) 
$(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
+CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
+AFLAGS := $(CFLAGS) -D__ASSEMBLY__
+
+NXFLATLDFLAGS1 = -r -d -warn-common
+NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) 
-T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
+LDNXFLATFLAGS = -e main -s 2048
diff --git a/boards/arm/stm32u0/stm32u083c-dk/scripts/flash.ld 
b/boards/arm/stm32u0/stm32u083c-dk/scripts/flash.ld
new file mode 100644
index 00000000000..50a1350c046
--- /dev/null
+++ b/boards/arm/stm32u0/stm32u083c-dk/scripts/flash.ld
@@ -0,0 +1,111 @@
+/****************************************************************************
+ * boards/arm/stm32u0/stm32u083c-dk/scripts/flash.ld
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/* The STM32U083MCT6 has 256KB of FLASH beginning at address 0x0800:0000 and
+ * 40Kb of SRAM at address 0x20000000 (32Kb SRAM1 + 8Kb backup SRAM2).
+ *
+ * When booting from FLASH, FLASH memory is aliased to address 0x0000:0000
+ * where the code expects to begin execution by jumping to the entry point in
+ * the 0x0800:0000 address range.
+ */
+
+MEMORY
+{
+  flash (rx) : ORIGIN = 0x08000000, LENGTH = 256K
+  sram (rwx) : ORIGIN = 0x20000000, LENGTH = 40K
+}
+
+OUTPUT_ARCH(arm)
+EXTERN(_vectors)
+ENTRY(_stext)
+
+SECTIONS
+{
+    .text :
+    {
+        _stext = ABSOLUTE(.);
+        *(.vectors)
+        *(.text .text.*)
+        *(.fixup)
+        *(.gnu.warning)
+        *(.rodata .rodata.*)
+        *(.gnu.linkonce.t.*)
+        *(.glue_7)
+        *(.glue_7t)
+        *(.got)
+        *(.gcc_except_table)
+        *(.gnu.linkonce.r.*)
+        _etext = ABSOLUTE(.);
+    } > flash
+
+    .init_section : ALIGN(4) {
+        _sinit = ABSOLUTE(.);
+        KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) 
SORT_BY_INIT_PRIORITY(.ctors.*)))
+        KEEP(*(.init_array EXCLUDE_FILE(*crtbegin.o *crtbegin?.o *crtend.o 
*crtend?.o) .ctors))
+        _einit = ABSOLUTE(.);
+    } > flash
+
+    .ARM.extab ALIGN(4): {
+        *(.ARM.extab*)
+    } > flash
+
+    .ARM.exidx : ALIGN(4) {
+        __exidx_start = ABSOLUTE(.);
+        *(.ARM.exidx*)
+        __exidx_end = ABSOLUTE(.);
+    } > flash
+
+    _eronly = ABSOLUTE(.);
+
+    .data : ALIGN(4) {
+        _sdata = ABSOLUTE(.);
+        *(.data .data.*)
+        *(.gnu.linkonce.d.*)
+        CONSTRUCTORS
+        . = ALIGN(4);
+        _edata = ABSOLUTE(.);
+    } > sram AT > flash
+
+    .bss : ALIGN(4) {
+        _sbss = ABSOLUTE(.);
+        *(.bss .bss.*)
+        *(.gnu.linkonce.b.*)
+        *(COMMON)
+        . = ALIGN(8);
+        _ebss = ABSOLUTE(.);
+    } > sram
+
+    /* Stabs debugging sections. */
+
+    .stab 0 : { *(.stab) }
+    .stabstr 0 : { *(.stabstr) }
+    .stab.excl 0 : { *(.stab.excl) }
+    .stab.exclstr 0 : { *(.stab.exclstr) }
+    .stab.index 0 : { *(.stab.index) }
+    .stab.indexstr 0 : { *(.stab.indexstr) }
+    .comment 0 : { *(.comment) }
+    .debug_abbrev 0 : { *(.debug_abbrev) }
+    .debug_info 0 : { *(.debug_info) }
+    .debug_line 0 : { *(.debug_line) }
+    .debug_pubnames 0 : { *(.debug_pubnames) }
+    .debug_aranges 0 : { *(.debug_aranges) }
+}
diff --git a/boards/arm/stm32u0/stm32u083c-dk/src/CMakeLists.txt 
b/boards/arm/stm32u0/stm32u083c-dk/src/CMakeLists.txt
new file mode 100644
index 00000000000..b96673d2bbc
--- /dev/null
+++ b/boards/arm/stm32u0/stm32u083c-dk/src/CMakeLists.txt
@@ -0,0 +1,40 @@
+# 
##############################################################################
+# boards/arm/stm32u0/stm32u083c-dk/src/CMakeLists.txt
+#
+# 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.
+#
+# 
##############################################################################
+
+set(SRCS stm32_boot.c stm32_bringup.c)
+
+if(CONFIG_ARCH_LEDS)
+  list(APPEND SRCS stm32_autoleds.c)
+else()
+  list(APPEND SRCS stm32_userleds.c)
+endif()
+
+if(CONFIG_ADC)
+  list(APPEND SRCS stm32_adc.c)
+  if(CONFIG_INPUT_DJOYSTICK)
+    list(APPEND SRCS stm32_djoystick.c)
+  endif()
+endif()
+
+target_sources(board PRIVATE ${SRCS})
+
+set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/flash.ld")
diff --git a/boards/arm/stm32u0/stm32u083c-dk/src/Make.defs 
b/boards/arm/stm32u0/stm32u083c-dk/src/Make.defs
new file mode 100644
index 00000000000..54d333da6bc
--- /dev/null
+++ b/boards/arm/stm32u0/stm32u083c-dk/src/Make.defs
@@ -0,0 +1,42 @@
+############################################################################
+# boards/arm/stm32u0/stm32u083c-dk/src/Make.defs
+#
+# 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.
+#
+############################################################################
+
+include $(TOPDIR)/Make.defs
+
+CSRCS = stm32_boot.c stm32_bringup.c
+
+ifeq ($(CONFIG_ARCH_LEDS),y)
+CSRCS += stm32_autoleds.c
+else
+CSRCS += stm32_userleds.c
+endif
+
+ifeq ($(CONFIG_ADC),y)
+CSRCS += stm32_adc.c
+ifeq ($(CONFIG_INPUT_DJOYSTICK),y)
+CSRCS += stm32_djoystick.c
+endif
+endif
+
+DEPPATH += --dep-path board
+VPATH += :board
+CFLAGS += 
${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board
diff --git a/boards/arm/stm32u0/stm32u083c-dk/src/stm32_adc.c 
b/boards/arm/stm32u0/stm32u083c-dk/src/stm32_adc.c
new file mode 100644
index 00000000000..3c89c555664
--- /dev/null
+++ b/boards/arm/stm32u0/stm32u083c-dk/src/stm32_adc.c
@@ -0,0 +1,127 @@
+/****************************************************************************
+ * boards/arm/stm32u0/stm32u083c-dk/src/stm32_adc.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 <stdbool.h>
+#include <errno.h>
+#include <nuttx/debug.h>
+
+#include <arch/board/board.h>
+
+#include <nuttx/analog/adc.h>
+
+#include "stm32.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Configuration ************************************************************/
+
+/* The number of ADC channels in the conversion list */
+
+#define ADC1_NCHANNELS 1
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* Identifying number of each ADC channel (even if NCHANNELS is less ) */
+
+static const uint8_t g_chanlist1[ADC1_NCHANNELS] =
+{
+  2,
+};
+
+/* Configurations of pins used by each ADC channel */
+
+static const uint32_t g_pinlist1[ADC1_NCHANNELS]  =
+{
+  GPIO_ADC1_IN2_1,                /* PC2 - joystick */
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32_adc_setup
+ *
+ * Description:
+ *   Initialize ADC and register the ADC driver.
+ *
+ ****************************************************************************/
+
+int stm32_adc_setup(void)
+{
+  static bool initialized = false;
+  struct adc_dev_s *adc;
+  int ret;
+  int i;
+
+  /* Check if we have already initialized */
+
+  if (!initialized)
+    {
+      /* Configure the pins as analog inputs for the selected channels */
+
+      for (i = 0; i < ADC1_NCHANNELS; i++)
+        {
+          stm32_configgpio(g_pinlist1[i]);
+        }
+
+      /* Call stm32_adcinitialize() to get an instance of the ADC interface */
+
+      adc = stm32_adcinitialize(1, g_chanlist1, ADC1_NCHANNELS);
+      if (adc == NULL)
+        {
+          aerr("ERROR: Failed to get ADC interface 1\n");
+          return -ENODEV;
+        }
+
+      /* Register the ADC driver at "/dev/adc0" */
+
+      ret = adc_register("/dev/adc0", adc);
+      if (ret < 0)
+        {
+          aerr("ERROR: adc_register /dev/adc0 failed: %d\n", ret);
+          return ret;
+        }
+
+      initialized = true;
+    }
+
+  return OK;
+}
diff --git a/boards/arm/stm32u0/stm32u083c-dk/src/stm32_autoleds.c 
b/boards/arm/stm32u0/stm32u083c-dk/src/stm32_autoleds.c
new file mode 100644
index 00000000000..4f4dff7feab
--- /dev/null
+++ b/boards/arm/stm32u0/stm32u083c-dk/src/stm32_autoleds.c
@@ -0,0 +1,82 @@
+/****************************************************************************
+ * boards/arm/stm32u0/stm32u083c-dk/src/stm32_autoleds.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 <stdint.h>
+#include <stdbool.h>
+#include <nuttx/debug.h>
+
+#include <nuttx/board.h>
+#include <arch/board/board.h>
+
+#include "chip.h"
+#include "arm_internal.h"
+#include "stm32_gpio.h"
+#include "stm32u083c-dk.h"
+
+#ifdef CONFIG_ARCH_LEDS
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_autoled_initialize
+ ****************************************************************************/
+
+void board_autoled_initialize(void)
+{
+  /* Configure LD3 GPIO for output */
+
+  stm32_configgpio(GPIO_LD3);
+}
+
+/****************************************************************************
+ * Name: board_autoled_on
+ ****************************************************************************/
+
+void board_autoled_on(int led)
+{
+  if (led == BOARD_LED1)
+    {
+      stm32_gpiowrite(GPIO_LD3, true);
+    }
+}
+
+/****************************************************************************
+ * Name: board_autoled_off
+ ****************************************************************************/
+
+void board_autoled_off(int led)
+{
+  if (led == BOARD_LED1)
+    {
+      stm32_gpiowrite(GPIO_LD3, false);
+    }
+}
+
+#endif /* CONFIG_ARCH_LEDS */
diff --git a/boards/arm/stm32u0/stm32u083c-dk/src/stm32_boot.c 
b/boards/arm/stm32u0/stm32u083c-dk/src/stm32_boot.c
new file mode 100644
index 00000000000..bec77b38cae
--- /dev/null
+++ b/boards/arm/stm32u0/stm32u083c-dk/src/stm32_boot.c
@@ -0,0 +1,83 @@
+/****************************************************************************
+ * boards/arm/stm32u0/stm32u083c-dk/src/stm32_boot.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 <nuttx/board.h>
+#include <arch/board/board.h>
+
+#include "stm32u083c-dk.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32_boardinitialize
+ *
+ * Description:
+ *   All STM32 architectures must provide the following entry point.  This
+ *   entry point is called early in the initialization -- after all memory
+ *   has been configured and mapped but before any devices have been
+ *   initialized.
+ *
+ ****************************************************************************/
+
+void stm32_boardinitialize(void)
+{
+#ifdef CONFIG_ARCH_LEDS
+  /* Configure on-board LEDs if LED support has been selected. */
+
+  board_autoled_initialize();
+#endif
+
+#ifdef CONFIG_STM32_SPI
+  /* Configure SPI chip selects */
+
+  stm32_spidev_initialize();
+#endif
+}
+
+/****************************************************************************
+ * Name: board_late_initialize
+ *
+ * Description:
+ *   If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional
+ *   initialization call will be performed in the boot-up sequence to a
+ *   function called board_late_initialize().  board_late_initialize() will
+ *   be called immediately after up_initialize() is called and just before
+ *   the initial application is started.  This additional initialization
+ *   phase may be used, for example, to initialize board-specific device
+ *   drivers.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_BOARD_LATE_INITIALIZE
+void board_late_initialize(void)
+{
+  stm32_bringup();
+}
+#endif
diff --git a/boards/arm/stm32u0/stm32u083c-dk/src/stm32_bringup.c 
b/boards/arm/stm32u0/stm32u083c-dk/src/stm32_bringup.c
new file mode 100644
index 00000000000..044140826ad
--- /dev/null
+++ b/boards/arm/stm32u0/stm32u083c-dk/src/stm32_bringup.c
@@ -0,0 +1,138 @@
+/****************************************************************************
+ * boards/arm/stm32u0/stm32u083c-dk/src/stm32_bringup.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 <nuttx/debug.h>
+
+#include <sys/types.h>
+
+#ifdef CONFIG_USERLED
+#  include <nuttx/leds/userled.h>
+#endif
+
+#ifdef CONFIG_STM32_IWDG
+#  include <stm32_wdg.h>
+#endif
+
+#ifdef CONFIG_SENSORS_QENCODER
+#  include "board_qencoder.h"
+#endif
+
+#ifdef CONFIG_PWM
+#  include "board_pwm.h"
+#endif
+
+#include <arch/board/board.h>
+
+#include "stm32u083c-dk.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32_bringup
+ *
+ * Description:
+ *   Perform architecture-specific initialization
+ *
+ *   CONFIG_BOARD_LATE_INITIALIZE=y :
+ *     Called from board_late_initialize().
+ *
+ ****************************************************************************/
+
+int stm32_bringup(void)
+{
+  int ret;
+
+#ifdef CONFIG_STM32_IWDG
+  /* Initialize the watchdog timer */
+
+  stm32_iwdginitialize("/dev/watchdog0", STM32_LSI_FREQUENCY);
+#endif
+
+#if !defined(CONFIG_ARCH_LEDS) && defined(CONFIG_USERLED_LOWER)
+  /* Register the LED driver */
+
+  ret = userled_lower_initialize(LED_DRIVER_PATH);
+  if (ret < 0)
+    {
+      syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret);
+      return ret;
+    }
+#endif
+
+#ifdef CONFIG_ADC
+  /* Initialize ADC and register the ADC driver. */
+
+  ret = stm32_adc_setup();
+  if (ret < 0)
+    {
+      syslog(LOG_ERR, "ERROR: stm32_adc_setup failed: %d\n", ret);
+    }
+
+#ifdef CONFIG_INPUT_DJOYSTICK
+  /* Initialize and register the joystick driver */
+
+  ret = stm32_djoy_initialize();
+  if (ret < 0)
+    {
+      syslog(LOG_ERR, "ERROR: stm32_djoy_initialize failed: %d\n", ret);
+    }
+#endif
+#endif
+
+#ifdef CONFIG_PWM
+  /* Initialize PWM and register the PWM device. */
+
+  ret = stm32_pwm_setup();
+  if (ret < 0)
+    {
+      syslog(LOG_ERR, "ERROR: stm32_pwm_setup failed: %d\n", ret);
+    }
+#endif
+
+#ifdef CONFIG_SENSORS_QENCODER
+  /* Initialize and register the qencoder driver - TIM3 */
+
+  ret = board_qencoder_initialize(0, 3);
+  if (ret != OK)
+    {
+      syslog(LOG_ERR,
+             "ERROR: Failed to register the qencoder: %d\n",
+             ret);
+      return ret;
+    }
+#endif
+
+  UNUSED(ret);
+  return OK;
+}
diff --git a/boards/arm/stm32u0/stm32u083c-dk/src/stm32_djoystick.c 
b/boards/arm/stm32u0/stm32u083c-dk/src/stm32_djoystick.c
new file mode 100644
index 00000000000..8b4c8855441
--- /dev/null
+++ b/boards/arm/stm32u0/stm32u083c-dk/src/stm32_djoystick.c
@@ -0,0 +1,394 @@
+/****************************************************************************
+ * boards/arm/stm32u0/stm32u083c-dk/src/stm32_djoystick.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 <stdint.h>
+#include <unistd.h>
+#include <nuttx/signal.h>
+#include <assert.h>
+#include <errno.h>
+#include <fcntl.h>
+
+#include <nuttx/debug.h>
+#include <nuttx/fs/fs.h>
+#include <nuttx/mutex.h>
+#include <nuttx/wqueue.h>
+#include <nuttx/clock.h>
+#include <nuttx/analog/adc.h>
+#include <nuttx/analog/ioctl.h>
+#include <nuttx/input/djoystick.h>
+
+#include "stm32u083c-dk.h"
+
+#if defined(CONFIG_INPUT_DJOYSTICK) && defined(CONFIG_ADC)
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifndef CONFIG_SCHED_WORKQUEUE
+#  error "The joystick driver requires CONFIG_SCHED_WORKQUEUE"
+#endif
+
+/* The 4-direction joystick with selection is connected to a resistor
+ * ladder on PC2 (ADC1 IN2).  The thresholds below decode the 12-bit
+ * conversion result into joystick positions (values from the ST BSP).
+ */
+
+#define JOY_ADC_DEVPATH    "/dev/adc0"
+#define JOY_ADC_CHANNEL    2
+#define JOY_ADC_NCHANNELS  1
+
+#define JOY_SEL_MAX        10
+#define JOY_LEFT_MIN       709
+#define JOY_LEFT_MAX       955
+#define JOY_DOWN_MIN       1514
+#define JOY_DOWN_MAX       1762
+#define JOY_UP_MIN         2370
+#define JOY_UP_MAX         2618
+#define JOY_RIGHT_MIN      3000
+#define JOY_RIGHT_MAX      3312
+
+/* Joystick polling interval */
+
+#define JOY_POLL_TICKS     MSEC2TICK(10)
+
+/* Bitset of supported joystick discretes */
+
+#define DJOY_SUPPORTED     (DJOY_UP_BIT | DJOY_DOWN_BIT | DJOY_LEFT_BIT | \
+                            DJOY_RIGHT_BIT | DJOY_BUTTON_SELECT_BIT)
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static djoy_buttonset_t
+  djoy_supported(const struct djoy_lowerhalf_s *lower);
+static djoy_buttonset_t djoy_sample_raw(void);
+static djoy_buttonset_t
+  djoy_sample(const struct djoy_lowerhalf_s *lower);
+static void djoy_enable(const struct djoy_lowerhalf_s *lower,
+                        djoy_buttonset_t press, djoy_buttonset_t release,
+                        djoy_interrupt_t handler, void *arg);
+
+static void djoy_worker(void *arg);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* The joystick ADC device file and access serialization */
+
+static struct file g_adcfile;
+static mutex_t g_adclock = NXMUTEX_INITIALIZER;
+
+/* Current interrupt handler, argument and event sets */
+
+static djoy_interrupt_t g_djoyhandler;
+static void *g_djoyarg;
+static djoy_buttonset_t g_djoypress;
+static djoy_buttonset_t g_djoyrelease;
+static djoy_buttonset_t g_djoysample;
+static bool g_djoyfirst;
+
+/* Joystick polling work */
+
+static struct work_s g_djoywork;
+
+/* This is the discrete joystick lower half driver interface */
+
+static const struct djoy_lowerhalf_s g_djoylower =
+{
+  .dl_supported  = djoy_supported,
+  .dl_sample     = djoy_sample,
+  .dl_enable     = djoy_enable,
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: djoy_supported
+ *
+ * Description:
+ *   Return the set of buttons supported on the discrete joystick device
+ *
+ ****************************************************************************/
+
+static djoy_buttonset_t
+  djoy_supported(const struct djoy_lowerhalf_s *lower)
+{
+  iinfo("Supported: %02x\n", DJOY_SUPPORTED);
+  return (djoy_buttonset_t)DJOY_SUPPORTED;
+}
+
+/****************************************************************************
+ * Name: djoy_decode
+ *
+ * Description:
+ *   Decode the joystick ADC value into a set of joystick discretes.
+ *
+ ****************************************************************************/
+
+static djoy_buttonset_t djoy_decode(int32_t data)
+{
+  if (data < JOY_SEL_MAX)
+    {
+      return DJOY_BUTTON_SELECT_BIT;
+    }
+  else if (data >= JOY_LEFT_MIN && data <= JOY_LEFT_MAX)
+    {
+      return DJOY_LEFT_BIT;
+    }
+  else if (data >= JOY_DOWN_MIN && data <= JOY_DOWN_MAX)
+    {
+      return DJOY_DOWN_BIT;
+    }
+  else if (data >= JOY_UP_MIN && data <= JOY_UP_MAX)
+    {
+      return DJOY_UP_BIT;
+    }
+  else if (data >= JOY_RIGHT_MIN && data <= JOY_RIGHT_MAX)
+    {
+      return DJOY_RIGHT_BIT;
+    }
+
+  return 0;
+}
+
+/****************************************************************************
+ * Name: djoy_sample_raw
+ *
+ * Description:
+ *   Sample the joystick ADC channel and decode the joystick state.  The
+ *   ADC device access is serialized since the joystick poll worker and
+ *   readers of other ADC channels can run concurrently.
+ *
+ ****************************************************************************/
+
+static djoy_buttonset_t djoy_sample_raw(void)
+{
+  struct adc_msg_s adcmsg[JOY_ADC_NCHANNELS];
+  djoy_buttonset_t sample = 0;
+  ssize_t nread;
+  int i;
+  int ret;
+
+  ret = nxmutex_lock(&g_adclock);
+  if (ret < 0)
+    {
+      return 0;
+    }
+
+  /* Drain any stale samples so that the channel data is not shifted
+   * against this conversion sequence.
+   */
+
+  while (file_read(&g_adcfile, adcmsg, sizeof(adcmsg)) > 0);
+
+  /* Trigger the ADC conversion of all configured channels */
+
+  ret = file_ioctl(&g_adcfile, ANIOC_TRIGGER, 0);
+  if (ret < 0)
+    {
+      ierr("ERROR: ANIOC_TRIGGER failed: %d\n", ret);
+      goto out;
+    }
+
+  /* Collect the fresh samples.  The device is opened in non-blocking
+   * mode, so poll for the completed conversions.
+   */
+
+  nread = 0;
+  for (i = 0; i < 10 && nread <= 0; i++)
+    {
+      nread = file_read(&g_adcfile, adcmsg, sizeof(adcmsg));
+      if (nread <= 0)
+        {
+          nxsig_usleep(1000);
+        }
+    }
+
+  if (nread < 0)
+    {
+      if (nread != -EAGAIN && nread != -EINTR)
+        {
+          ierr("ERROR: read failed: %d\n", (int)nread);
+        }
+
+      goto out;
+    }
+
+  /* Find the joystick channel and decode it */
+
+  for (i = 0; i < nread / (ssize_t)sizeof(struct adc_msg_s); i++)
+    {
+      if (adcmsg[i].am_channel == JOY_ADC_CHANNEL)
+        {
+          sample = djoy_decode(adcmsg[i].am_data);
+          break;
+        }
+    }
+
+out:
+  nxmutex_unlock(&g_adclock);
+  return sample;
+}
+
+/****************************************************************************
+ * Name: djoy_sample
+ *
+ * Description:
+ *   Return the current state of all discrete joystick buttons.  While the
+ *   poll worker is running the last polled state is returned so that
+ *   driver reads do not compete with the worker for the ADC device.
+ *
+ ****************************************************************************/
+
+static djoy_buttonset_t djoy_sample(const struct djoy_lowerhalf_s *lower)
+{
+  if (g_djoyhandler != NULL)
+    {
+      return g_djoysample;
+    }
+
+  return djoy_sample_raw();
+}
+
+/****************************************************************************
+ * Name: djoy_worker
+ *
+ * Description:
+ *   Periodically sample the joystick state and notify the upper half
+ *   driver when a joystick event of interest occurs.
+ *
+ ****************************************************************************/
+
+static void djoy_worker(void *arg)
+{
+  djoy_buttonset_t sample;
+
+  if (g_djoyhandler == NULL)
+    {
+      return;
+    }
+
+  sample = djoy_sample_raw();
+  if (g_djoyfirst)
+    {
+      /* Just establish the joystick state baseline after enable */
+
+      g_djoyfirst  = false;
+      g_djoysample = sample;
+    }
+  else if (((g_djoypress & sample & ~g_djoysample) != 0) ||
+           ((g_djoyrelease & g_djoysample & ~sample) != 0))
+    {
+      g_djoysample = sample;
+      g_djoyhandler(&g_djoylower, g_djoyarg);
+    }
+  else
+    {
+      g_djoysample = sample;
+    }
+
+  work_queue(LPWORK, &g_djoywork, djoy_worker, NULL, JOY_POLL_TICKS);
+}
+
+/****************************************************************************
+ * Name: djoy_enable
+ *
+ * Description:
+ *   Enable joystick event notifications.  There are no interrupt sources
+ *   available for the ADC-based joystick, so the joystick state is polled
+ *   periodically from the low priority work queue.
+ *
+ *   NOTE: the upper half driver can call this function with a critical
+ *   section held, so it must not block.  The ADC is accessed only from
+ *   the poll worker.
+ *
+ ****************************************************************************/
+
+static void djoy_enable(const struct djoy_lowerhalf_s *lower,
+                        djoy_buttonset_t press, djoy_buttonset_t release,
+                        djoy_interrupt_t handler, void *arg)
+{
+  work_cancel(LPWORK, &g_djoywork);
+
+  g_djoypress   = press;
+  g_djoyrelease = release;
+  g_djoyhandler = handler;
+  g_djoyarg     = arg;
+
+  if (handler != NULL)
+    {
+      g_djoyfirst = true;
+      work_queue(LPWORK, &g_djoywork, djoy_worker, NULL, 0);
+    }
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32_djoy_initialize
+ *
+ * Description:
+ *   Initialize and register the discrete joystick driver
+ *
+ ****************************************************************************/
+
+int stm32_djoy_initialize(void)
+{
+  int ret;
+
+  /* Open the joystick ADC device.  The ADC driver must be registered
+   * before this function is called.
+   */
+
+  ret = file_open(&g_adcfile, JOY_ADC_DEVPATH, O_RDONLY | O_NONBLOCK);
+  if (ret < 0)
+    {
+      ierr("ERROR: Failed to open %s: %d\n", JOY_ADC_DEVPATH, ret);
+      return ret;
+    }
+
+  /* Register the joystick device as /dev/djoy0 */
+
+  ret = djoy_register("/dev/djoy0", &g_djoylower);
+  if (ret < 0)
+    {
+      ierr("ERROR: djoy_register failed: %d\n", ret);
+      file_close(&g_adcfile);
+    }
+
+  return ret;
+}
+
+#endif /* CONFIG_INPUT_DJOYSTICK && CONFIG_ADC */
diff --git a/boards/arm/stm32u0/stm32u083c-dk/src/stm32_userleds.c 
b/boards/arm/stm32u0/stm32u083c-dk/src/stm32_userleds.c
new file mode 100644
index 00000000000..878a6197414
--- /dev/null
+++ b/boards/arm/stm32u0/stm32u083c-dk/src/stm32_userleds.c
@@ -0,0 +1,179 @@
+/****************************************************************************
+ * boards/arm/stm32u0/stm32u083c-dk/src/stm32_userleds.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 <stdint.h>
+#include <stdbool.h>
+#include <assert.h>
+#include <nuttx/debug.h>
+
+#include <arch/board/board.h>
+#include <nuttx/power/pm.h>
+
+#include "chip.h"
+#include "arm_internal.h"
+#include "stm32_gpio.h"
+#include "stm32u083c-dk.h"
+
+#ifndef CONFIG_ARCH_LEDS
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/* LED Power Management */
+
+#ifdef CONFIG_PM
+static void led_pm_notify(struct pm_callback_s *cb, int domain,
+                          enum pm_state_e pmstate);
+static int led_pm_prepare(struct pm_callback_s *cb, int domain,
+                          enum pm_state_e pmstate);
+#endif
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+#ifdef CONFIG_PM
+static struct pm_callback_s g_ledscb =
+{
+  .notify  = led_pm_notify,
+  .prepare = led_pm_prepare,
+};
+#endif
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: led_pm_notify
+ *
+ * Description:
+ *   Notify the driver of new power state. This callback is called after
+ *   all drivers have had the opportunity to prepare for the new power state.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_PM
+static void led_pm_notify(struct pm_callback_s *cb, int domain,
+                          enum pm_state_e pmstate)
+{
+}
+#endif
+
+/****************************************************************************
+ * Name: led_pm_prepare
+ *
+ * Description:
+ *   Request the driver to prepare for a new power state. This is a warning
+ *   that the system is about to enter into a new power state. The driver
+ *   should begin whatever operations that may be required to enter power
+ *   state. The driver may abort the state change mode by returning a
+ *   non-zero value from the callback function.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_PM
+static int led_pm_prepare(struct pm_callback_s *cb, int domain,
+                          enum pm_state_e pmstate)
+{
+  /* No preparation to change power modes is required by the LEDs driver.
+   * We always accept the state change by returning OK.
+   */
+
+  return OK;
+}
+#endif
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_userled_initialize
+ ****************************************************************************/
+
+uint32_t board_userled_initialize(void)
+{
+  /* Configure LD3, LD4 and LD5 GPIO for output */
+
+  stm32_configgpio(GPIO_LD3);
+  stm32_configgpio(GPIO_LD4);
+  stm32_configgpio(GPIO_LD5);
+  return BOARD_NLEDS;
+}
+
+/****************************************************************************
+ * Name: board_userled
+ ****************************************************************************/
+
+void board_userled(int led, bool ledon)
+{
+  if (led == BOARD_LED1)
+    {
+      stm32_gpiowrite(GPIO_LD3, ledon);
+    }
+
+  if (led == BOARD_LED2)
+    {
+      stm32_gpiowrite(GPIO_LD4, ledon);
+    }
+
+  if (led == BOARD_LED3)
+    {
+      stm32_gpiowrite(GPIO_LD5, ledon);
+    }
+}
+
+/****************************************************************************
+ * Name: board_userled_all
+ ****************************************************************************/
+
+void board_userled_all(uint32_t ledset)
+{
+  stm32_gpiowrite(GPIO_LD3, (ledset & BOARD_LED1_BIT) != 0);
+  stm32_gpiowrite(GPIO_LD4, (ledset & BOARD_LED2_BIT) != 0);
+  stm32_gpiowrite(GPIO_LD5, (ledset & BOARD_LED3_BIT) != 0);
+}
+
+/****************************************************************************
+ * Name: stm32_led_pminitialize
+ ****************************************************************************/
+
+#ifdef CONFIG_PM
+void stm32_led_pminitialize(void)
+{
+  /* Register to receive power management callbacks */
+
+  int ret = pm_register(&g_ledscb);
+  DEBUGASSERT(ret == OK);
+  UNUSED(ret);
+}
+#endif /* CONFIG_PM */
+
+#endif /* !CONFIG_ARCH_LEDS */
diff --git a/boards/arm/stm32u0/stm32u083c-dk/src/stm32u083c-dk.h 
b/boards/arm/stm32u0/stm32u083c-dk/src/stm32u083c-dk.h
new file mode 100644
index 00000000000..14cdf965b1d
--- /dev/null
+++ b/boards/arm/stm32u0/stm32u083c-dk/src/stm32u083c-dk.h
@@ -0,0 +1,109 @@
+/****************************************************************************
+ * boards/arm/stm32u0/stm32u083c-dk/src/stm32u083c-dk.h
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __BOARDS_ARM_STM32U0_STM32U083C_DK_SRC_STM32U083C_DK_H
+#define __BOARDS_ARM_STM32U0_STM32U083C_DK_SRC_STM32U083C_DK_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/compiler.h>
+#include <stdint.h>
+
+#include "stm32_gpio.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* STM32U083C-DK GPIOs ******************************************************/
+
+/* User LEDs:
+ *  LD3 (green) - PC13
+ *  LD4 (blue)  - PA5
+ *  LD5 (red)   - PB2
+ */
+
+#define GPIO_LD3        (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_MEDIUM | \
+                         GPIO_OUTPUT_CLEAR | GPIO_PORTC | GPIO_PIN13)
+#define GPIO_LD4        (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_MEDIUM | \
+                         GPIO_OUTPUT_CLEAR | GPIO_PORTA | GPIO_PIN5)
+#define GPIO_LD5        (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_MEDIUM | \
+                         GPIO_OUTPUT_CLEAR | GPIO_PORTB | GPIO_PIN2)
+
+#define LED_DRIVER_PATH "/dev/userleds"
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+#ifndef __ASSEMBLY__
+
+/****************************************************************************
+ * Public Functions Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32_bringup
+ *
+ * Description:
+ *   Perform architecture-specific initialization
+ *
+ *   CONFIG_BOARD_LATE_INITIALIZE=y :
+ *     Called from board_late_initialize().
+ *
+ ****************************************************************************/
+
+int stm32_bringup(void);
+
+/****************************************************************************
+ * Name: stm32_adc_setup
+ *
+ * Description:
+ *   Initialize ADC and register the ADC driver.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ADC
+int stm32_adc_setup(void);
+#endif
+
+/****************************************************************************
+ * Name: stm32_djoy_initialize
+ *
+ * Description:
+ *   Initialize and register the discrete joystick driver
+ *
+ ****************************************************************************/
+
+#if defined(CONFIG_INPUT_DJOYSTICK) && defined(CONFIG_ADC)
+int stm32_djoy_initialize(void);
+#endif
+
+#endif /* __ASSEMBLY__ */
+#endif /* __BOARDS_ARM_STM32U0_STM32U083C_DK_SRC_STM32U083C_DK_H */

Reply via email to