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

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

commit ef17efa2147473f2118a05f7e81a54c882615da0
Author: Alan Carvalho de Assis <[email protected]>
AuthorDate: Wed Nov 11 19:12:28 2026 -0300

    boards/stm32l0: add the nPZero G1S Development Kit board
    
    Add support for the STM32L053C8U6 MCU host of the Nanopower nPZero G1S
    Development Kit (NPZ-G1S-DK):
    * SYSCLK is the 16 MHz HSI (no crystal on the MCU host, and the STM32 I2C
      driver expects a 16 MHz I2C clock).
    * USART2 (PA2/PA3) is the console, on the MCU UART connector J19.
    * I2C1 (PB6/PB7) is the nPZero bus, the nPZero driver is registered as
      /dev/npzero0 at boot.
    * PA12 is the LED.
    
    The host I2C bus is shared with the sensor boards.  After a reset of the
    nPZero their power switches are off and the unpowered AS6212 board on
    PMOD 4 slows down SDA (about 10 us, 100 us when SCL is low): the STM32
    reports an arbitration loss.  The new CONFIG_NPZERO_G1S_DK_PMOD_POWER
    option (default y) enables the power switches of PMOD 3 and 4 (PSWCTL,
    read-modify-write) with a bit-banged I2C transfer at about 2 kHz before
    the I2C driver is initialized.
    
    Configurations:
    * nsh: NSH with the npzero example.  The 8 KB of SRAM is the limit: it
      uses CONFIG_DEFAULT_SMALL with ls, cat and echo, a 1792-byte NSH stack
      (ls peaks at about 1.3 KB) and smaller idle and init thread stacks.
    * npzero: the npzero example is the entry point, without NSH.
    
    Tested on the DevKit with npzero-g1s-dk:nsh, with the AS6212 board on
    PMOD 4, after a reset of the nPZero (S5):
    
      nsh> npzero -s
      nPZero G1S ID: 0x60
      STA1: 0x01 STA2: 0x00
      nsh> npzero
      nPZero G1S ID: 0x60
      STA1: 0x01 STA2: 0x00
      Configured, Idle state in 1000 ms
    
    The host is then switched off and woken up again by the nPZero.  The
    npzero configuration builds but was not run on the board.
    
    Signed-off-by: Alan C. Assis <[email protected]>
    Assisted-by: Claude:claude-opus-5-5
---
 boards/Kconfig                                     |  13 +
 boards/arm/stm32l0/npzero-g1s-dk/CMakeLists.txt    |  23 ++
 boards/arm/stm32l0/npzero-g1s-dk/Kconfig           |  21 ++
 .../stm32l0/npzero-g1s-dk/configs/npzero/defconfig |  50 ++++
 .../stm32l0/npzero-g1s-dk/configs/nsh/defconfig    |  56 ++++
 boards/arm/stm32l0/npzero-g1s-dk/include/board.h   | 149 +++++++++++
 boards/arm/stm32l0/npzero-g1s-dk/scripts/Make.defs |  40 +++
 boards/arm/stm32l0/npzero-g1s-dk/scripts/ld.script | 115 +++++++++
 .../arm/stm32l0/npzero-g1s-dk/src/CMakeLists.txt   |  31 +++
 boards/arm/stm32l0/npzero-g1s-dk/src/Make.defs     |  31 +++
 .../arm/stm32l0/npzero-g1s-dk/src/npzero-g1s-dk.h  |  78 ++++++
 .../arm/stm32l0/npzero-g1s-dk/src/stm32_autoleds.c |  80 ++++++
 boards/arm/stm32l0/npzero-g1s-dk/src/stm32_boot.c  |  79 ++++++
 .../arm/stm32l0/npzero-g1s-dk/src/stm32_bringup.c  | 284 +++++++++++++++++++++
 14 files changed, 1050 insertions(+)

diff --git a/boards/Kconfig b/boards/Kconfig
index 0f180dfb868..c5012afdf3a 100644
--- a/boards/Kconfig
+++ b/boards/Kconfig
@@ -3308,6 +3308,15 @@ config ARCH_BOARD_STM3240G_EVAL
                microcontroller (ARM Cortex-M4 with FPU).  This port uses a GNU 
Cortex-M4
                toolchain (such as CodeSourcery).
 
+config ARCH_BOARD_NPZERO_G1S_DK
+       bool "Nanopower nPZero G1S Development Kit (STM32L053C8 host)"
+       depends on ARCH_CHIP_STM32L053C8
+       select ARCH_HAVE_LEDS
+       ---help---
+               Nanopower nPZero G1S Development Kit with its STM32L053C8U6 MCU
+               host board.  The host controls the nPZero G1S power-saving IC 
over
+               I2C1.
+
 config ARCH_BOARD_STM32L0538_DISCO
        bool "STMicro STM32L0538-Disco board"
        depends on ARCH_CHIP_STM32L053C8
@@ -4475,6 +4484,7 @@ config ARCH_BOARD
        default "pnev5180b"                    if ARCH_BOARD_PNEV5180B
        default "stm32butterfly2"              if ARCH_BOARD_STM32_BUTTERFLY2
        default "stm32_tiny"                   if ARCH_BOARD_STM32_TINY
+       default "npzero-g1s-dk"                if ARCH_BOARD_NPZERO_G1S_DK
        default "stm32l0538-disco"             if ARCH_BOARD_STM32L0538_DISCO
        default "stm32f051-discovery"          if ARCH_BOARD_STM32F051_DISCOVERY
        default "stm32f072-discovery"          if ARCH_BOARD_STM32F072_DISCOVERY
@@ -5108,6 +5118,9 @@ endif
 if ARCH_BOARD_STM32F051_DISCOVERY
 source "boards/arm/stm32f0/stm32f051-discovery/Kconfig"
 endif
+if ARCH_BOARD_NPZERO_G1S_DK
+source "boards/arm/stm32l0/npzero-g1s-dk/Kconfig"
+endif
 if ARCH_BOARD_STM32L0538_DISCO
 source "boards/arm/stm32l0/stm32l0538-disco/Kconfig"
 endif
diff --git a/boards/arm/stm32l0/npzero-g1s-dk/CMakeLists.txt 
b/boards/arm/stm32l0/npzero-g1s-dk/CMakeLists.txt
new file mode 100644
index 00000000000..7e255264883
--- /dev/null
+++ b/boards/arm/stm32l0/npzero-g1s-dk/CMakeLists.txt
@@ -0,0 +1,23 @@
+# 
##############################################################################
+# boards/arm/stm32l0/npzero-g1s-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/stm32l0/npzero-g1s-dk/Kconfig 
b/boards/arm/stm32l0/npzero-g1s-dk/Kconfig
new file mode 100644
index 00000000000..f1c2814b2fd
--- /dev/null
+++ b/boards/arm/stm32l0/npzero-g1s-dk/Kconfig
@@ -0,0 +1,21 @@
+#
+# For a description of the syntax of this configuration file,
+# see the file kconfig-language.txt in the NuttX tools repository.
+#
+
+if ARCH_BOARD_NPZERO_G1S_DK
+
+config NPZERO_G1S_DK_PMOD_POWER
+       bool "Power the PMOD 3 and 4 peripherals at boot"
+       default y
+       depends on NPZERO
+       ---help---
+               After a reset of the nPZero, the power switches of the
+               peripherals are off.  An unpowered sensor board on the I2C bus
+               (the AS6212 on PMOD 4) slows down SDA so much that the STM32 I2C
+               controller cannot talk to the nPZero.  If this option is
+               selected, the power switches of PMOD 3 and 4 are enabled
+               (PSWCTL) with a slow bit-banged I2C transfer, before the I2C
+               driver is initialized.
+
+endif
diff --git a/boards/arm/stm32l0/npzero-g1s-dk/configs/npzero/defconfig 
b/boards/arm/stm32l0/npzero-g1s-dk/configs/npzero/defconfig
new file mode 100644
index 00000000000..414bbc82409
--- /dev/null
+++ b/boards/arm/stm32l0/npzero-g1s-dk/configs/npzero/defconfig
@@ -0,0 +1,50 @@
+#
+# 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="npzero-g1s-dk"
+CONFIG_ARCH_BOARD_NPZERO_G1S_DK=y
+CONFIG_ARCH_CHIP="stm32l0"
+CONFIG_ARCH_CHIP_STM32=y
+CONFIG_ARCH_CHIP_STM32L053C8=y
+CONFIG_ARCH_CHIP_STM32L053XX=y
+CONFIG_ARCH_CHIP_STM32L0=y
+CONFIG_ARCH_STACKDUMP=y
+CONFIG_BOARD_INITTHREAD_STACKSIZE=768
+CONFIG_BOARD_LOOPSPERMSEC=1398
+CONFIG_DEBUG_FULLOPT=y
+CONFIG_DEBUG_SYMBOLS=y
+CONFIG_DEFAULT_TASK_STACKSIZE=1024
+CONFIG_DISABLE_ENVIRON=y
+CONFIG_DISABLE_MOUNTPOINT=y
+CONFIG_DISABLE_MQUEUE=y
+CONFIG_DISABLE_POSIX_TIMERS=y
+CONFIG_DISABLE_PSEUDOFS_OPERATIONS=y
+CONFIG_EXAMPLES_NPZERO=y
+CONFIG_EXPERIMENTAL=y
+CONFIG_I2C=y
+CONFIG_IDLETHREAD_STACKSIZE=768
+CONFIG_INIT_ENTRYPOINT="npzero_main"
+CONFIG_INTELHEX_BINARY=y
+CONFIG_LTO_FULL=y
+CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
+CONFIG_NPZERO=y
+CONFIG_PTHREAD_MUTEX_UNSAFE=y
+CONFIG_RAM_SIZE=8192
+CONFIG_RAM_START=0x20000000
+CONFIG_RAW_BINARY=y
+CONFIG_RR_INTERVAL=200
+CONFIG_SCHED_WAITPID=y
+CONFIG_START_DAY=11
+CONFIG_START_MONTH=11
+CONFIG_START_YEAR=2026
+CONFIG_STDIO_DISABLE_BUFFERING=y
+CONFIG_STM32_I2C1=y
+CONFIG_STM32_PWR=y
+CONFIG_STM32_USART2=y
+CONFIG_TASK_NAME_SIZE=0
+CONFIG_USART2_SERIAL_CONSOLE=y
diff --git a/boards/arm/stm32l0/npzero-g1s-dk/configs/nsh/defconfig 
b/boards/arm/stm32l0/npzero-g1s-dk/configs/nsh/defconfig
new file mode 100644
index 00000000000..82db2bd4e1f
--- /dev/null
+++ b/boards/arm/stm32l0/npzero-g1s-dk/configs/nsh/defconfig
@@ -0,0 +1,56 @@
+#
+# 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_DISABLE_DIRECTORY_OPERATIONS is not set
+# CONFIG_NSH_DISABLE_CAT is not set
+# CONFIG_NSH_DISABLE_ECHO is not set
+# CONFIG_NSH_DISABLE_LS is not set
+CONFIG_ARCH="arm"
+CONFIG_ARCH_BOARD="npzero-g1s-dk"
+CONFIG_ARCH_BOARD_NPZERO_G1S_DK=y
+CONFIG_ARCH_CHIP="stm32l0"
+CONFIG_ARCH_CHIP_STM32=y
+CONFIG_ARCH_CHIP_STM32L053C8=y
+CONFIG_ARCH_CHIP_STM32L053XX=y
+CONFIG_ARCH_CHIP_STM32L0=y
+CONFIG_ARCH_STACKDUMP=y
+CONFIG_BOARD_INITTHREAD_STACKSIZE=768
+CONFIG_BOARD_LOOPSPERMSEC=1398
+CONFIG_BUILTIN=y
+CONFIG_DEBUG_FULLOPT=y
+CONFIG_DEBUG_SYMBOLS=y
+CONFIG_DEFAULT_SMALL=y
+CONFIG_DEFAULT_TASK_STACKSIZE=1024
+CONFIG_DISABLE_MOUNTPOINT=y
+CONFIG_EXAMPLES_NPZERO=y
+CONFIG_EXPERIMENTAL=y
+CONFIG_I2C=y
+CONFIG_IDLETHREAD_STACKSIZE=640
+CONFIG_INIT_ENTRYPOINT="nsh_main"
+CONFIG_INIT_STACKSIZE=1792
+CONFIG_INTELHEX_BINARY=y
+CONFIG_LTO_FULL=y
+CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
+CONFIG_NPZERO=y
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_FILEIOSIZE=64
+CONFIG_NUNGET_CHARS=0
+CONFIG_PATH_MAX=64
+CONFIG_RAM_SIZE=8192
+CONFIG_RAM_START=0x20000000
+CONFIG_RAW_BINARY=y
+CONFIG_RR_INTERVAL=200
+CONFIG_SCHED_WAITPID=y
+CONFIG_START_DAY=11
+CONFIG_START_MONTH=11
+CONFIG_START_YEAR=2026
+CONFIG_STM32_I2C1=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/stm32l0/npzero-g1s-dk/include/board.h 
b/boards/arm/stm32l0/npzero-g1s-dk/include/board.h
new file mode 100644
index 00000000000..13f0c86a548
--- /dev/null
+++ b/boards/arm/stm32l0/npzero-g1s-dk/include/board.h
@@ -0,0 +1,149 @@
+/****************************************************************************
+ * boards/arm/stm32l0/npzero-g1s-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_STM32L0_NPZERO_G1S_DK_INCLUDE_BOARD_H
+#define __BOARDS_ARM_STM32L0_NPZERO_G1S_DK_INCLUDE_BOARD_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Clocking *****************************************************************/
+
+/* The STM32 MCU host of the nPZero G1S Development Kit has no crystal:
+ *
+ * HSI - Internal 16 MHz RC Oscillator
+ * LSI - 37 KHz RC
+ */
+
+#define STM32_HSI_FREQUENCY     16000000ul
+#define STM32_LSI_FREQUENCY     37000            /* Between 26kHz and 56kHz */
+#define STM32_HSE_FREQUENCY     0
+#define STM32_LSE_FREQUENCY     0
+
+/* The PLL is not used */
+
+#define STM32_CFGR_PLLSRC       0
+#define STM32_CFGR_PLLXTPRE     0
+#define STM32_CFGR_PLLMUL       0
+#define STM32_CFGR_PLLDIV       0
+
+/* SYSCLK is HSI (16MHz).  It keeps the consumption low and it is the
+ * clock expected by the I2C driver for its timings.
+ */
+
+#define STM32_SYSCLK_SW         RCC_CFGR_SW_HSI
+#define STM32_SYSCLK_SWS        RCC_CFGR_SWS_HSI
+#define STM32_SYSCLK_FREQUENCY  STM32_HSI_FREQUENCY
+
+/* AHB clock (HCLK) is SYSCLK (16MHz) */
+
+#define STM32_RCC_CFGR_HPRE     RCC_CFGR_HPRE_SYSCLK
+#define STM32_HCLK_FREQUENCY    STM32_SYSCLK_FREQUENCY
+
+/* APB2 clock (PCLK2) is HCLK (16MHz) */
+
+#define STM32_RCC_CFGR_PPRE2    RCC_CFGR_PPRE2_HCLK
+#define STM32_PCLK2_FREQUENCY   STM32_HCLK_FREQUENCY
+#define STM32_APB2_CLKIN        (STM32_PCLK2_FREQUENCY)
+
+/* APB1 clock (PCLK1) is HCLK (16MHz) */
+
+#define STM32_RCC_CFGR_PPRE1    RCC_CFGR_PPRE1_HCLK
+#define STM32_PCLK1_FREQUENCY   STM32_HCLK_FREQUENCY
+
+/* APB1 timers 2, 3, 6 and 7 will receive PCLK1 */
+
+#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)
+
+/* LED definitions **********************************************************/
+
+/* The STM32 MCU host has one LED, connected to PA12 (high to light it).
+ * The LEDs D1-D6 of the DevBoard show the state of the power switches of
+ * the nPZero and they are not controlled by the MCU.
+ *
+ * If CONFIG_ARCH_LEDS is not defined, then the user can control the LED in
+ * any way.  The following definition is used to access the LED.
+ */
+
+/* LED index values for use with board_userled() */
+
+#define BOARD_LED1       0
+#define BOARD_NLEDS      1
+
+/* LED bits for use with board_userled_all() */
+
+#define BOARD_LED1_BIT   (1 << BOARD_LED1)
+
+/* If CONFIG_ARCH_LEDS is defined, then NuttX will control the LED.  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
+
+/* Alternate function pin selections ****************************************/
+
+/* USART2 is the console, on the MCU UART connector J19 of the DevBoard:
+ *   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 */
+
+/* I2C1 is connected to the nPZero G1S (host I2C of the DevBoard):
+ *   I2C1_SCL - PB6
+ *   I2C1_SDA - PB7
+ */
+
+#define GPIO_I2C1_SCL    (GPIO_I2C1_SCL_1|GPIO_PULLUP|GPIO_SPEED_LOW) /* PB6 */
+#define GPIO_I2C1_SDA    (GPIO_I2C1_SDA_1|GPIO_PULLUP|GPIO_SPEED_LOW) /* PB7 */
+
+#endif /* __BOARDS_ARM_STM32L0_NPZERO_G1S_DK_INCLUDE_BOARD_H */
diff --git a/boards/arm/stm32l0/npzero-g1s-dk/scripts/Make.defs 
b/boards/arm/stm32l0/npzero-g1s-dk/scripts/Make.defs
new file mode 100644
index 00000000000..6255411ef43
--- /dev/null
+++ b/boards/arm/stm32l0/npzero-g1s-dk/scripts/Make.defs
@@ -0,0 +1,40 @@
+############################################################################
+# boards/arm/stm32l0/npzero-g1s-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 = ld.script
+ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
+
+ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef
+ARCHWARNINGSXX = -Wall -Wshadow -Wundef
+
+CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) 
$(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
+CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(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/stm32l0/npzero-g1s-dk/scripts/ld.script 
b/boards/arm/stm32l0/npzero-g1s-dk/scripts/ld.script
new file mode 100644
index 00000000000..acb155cb20b
--- /dev/null
+++ b/boards/arm/stm32l0/npzero-g1s-dk/scripts/ld.script
@@ -0,0 +1,115 @@
+/****************************************************************************
+ * boards/arm/stm32l0/npzero-g1s-dk/scripts/ld.script
+ *
+ * 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 STM32L053C8 has 64Kb of FLASH beginning at address 0x0800:0000,
+ * 8Kb of SRAM and 2Kb of EEPROM.
+ *
+ * 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 = 64K
+  sram (rwx) : ORIGIN = 0x20000000, LENGTH = 8K
+}
+
+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(.);
+
+    /* The RAM vector table (if present) should lie at the beginning of SRAM */
+
+    .ram_vectors : {
+        *(.ram_vectors)
+    } > sram
+
+    .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/stm32l0/npzero-g1s-dk/src/CMakeLists.txt 
b/boards/arm/stm32l0/npzero-g1s-dk/src/CMakeLists.txt
new file mode 100644
index 00000000000..a48c5f3b2b4
--- /dev/null
+++ b/boards/arm/stm32l0/npzero-g1s-dk/src/CMakeLists.txt
@@ -0,0 +1,31 @@
+# 
##############################################################################
+# boards/arm/stm32l0/npzero-g1s-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)
+endif()
+
+target_sources(board PRIVATE ${SRCS})
+
+set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/ld.script")
diff --git a/boards/arm/stm32l0/npzero-g1s-dk/src/Make.defs 
b/boards/arm/stm32l0/npzero-g1s-dk/src/Make.defs
new file mode 100644
index 00000000000..c8bb374679c
--- /dev/null
+++ b/boards/arm/stm32l0/npzero-g1s-dk/src/Make.defs
@@ -0,0 +1,31 @@
+############################################################################
+# boards/arm/stm32l0/npzero-g1s-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.
+#
+############################################################################
+
+CSRCS = stm32_boot.c stm32_bringup.c
+
+ifeq ($(CONFIG_ARCH_LEDS),y)
+CSRCS += stm32_autoleds.c
+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/stm32l0/npzero-g1s-dk/src/npzero-g1s-dk.h 
b/boards/arm/stm32l0/npzero-g1s-dk/src/npzero-g1s-dk.h
new file mode 100644
index 00000000000..88f6d752a12
--- /dev/null
+++ b/boards/arm/stm32l0/npzero-g1s-dk/src/npzero-g1s-dk.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+ * boards/arm/stm32l0/npzero-g1s-dk/src/npzero-g1s-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_STM32L0_NPZERO_G1S_DK_SRC_NPZERO_G1S_DK_H
+#define __BOARDS_ARM_STM32L0_NPZERO_G1S_DK_SRC_NPZERO_G1S_DK_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* LED definitions **********************************************************/
+
+/* The STM32 MCU host has one LED connected to PA12, lit when PA12 is high */
+
+#define GPIO_LED1      (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_LOW | \
+                        GPIO_OUTPUT_CLEAR | GPIO_PORTA | GPIO_PIN12)
+
+/* nPZero G1S ***************************************************************/
+
+/* The nPZero G1S is on I2C1 */
+
+#define NPZERO_I2C_BUS  1
+#define NPZERO_DEVPATH  "/dev/npzero0"
+
+/* I2C1 pins as open-drain GPIOs, used to power the PMOD peripherals before
+ * the I2C driver is initialized (see stm32_bringup.c).
+ */
+
+#define GPIO_NPZERO_SCL (GPIO_OUTPUT | GPIO_OPENDRAIN | GPIO_PULLUP | \
+                         GPIO_SPEED_LOW | GPIO_OUTPUT_SET | GPIO_PORTB | \
+                         GPIO_PIN6)
+#define GPIO_NPZERO_SDA (GPIO_OUTPUT | GPIO_OPENDRAIN | GPIO_PULLUP | \
+                         GPIO_SPEED_LOW | GPIO_OUTPUT_SET | GPIO_PORTB | \
+                         GPIO_PIN7)
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32_bringup
+ *
+ * Description:
+ *   Perform architecture-specific initialization
+ *
+ *   CONFIG_BOARD_LATE_INITIALIZE=y :
+ *     Called from board_late_initialize().
+ *
+ ****************************************************************************/
+
+int stm32_bringup(void);
+
+#endif /* __BOARDS_ARM_STM32L0_NPZERO_G1S_DK_SRC_NPZERO_G1S_DK_H */
diff --git a/boards/arm/stm32l0/npzero-g1s-dk/src/stm32_autoleds.c 
b/boards/arm/stm32l0/npzero-g1s-dk/src/stm32_autoleds.c
new file mode 100644
index 00000000000..03d46e2c816
--- /dev/null
+++ b/boards/arm/stm32l0/npzero-g1s-dk/src/stm32_autoleds.c
@@ -0,0 +1,80 @@
+/****************************************************************************
+ * boards/arm/stm32l0/npzero-g1s-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/board.h>
+
+#include "stm32_gpio.h"
+#include "npzero-g1s-dk.h"
+
+#include <arch/board/board.h>
+
+#ifdef CONFIG_ARCH_LEDS
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_autoled_initialize
+ ****************************************************************************/
+
+void board_autoled_initialize(void)
+{
+  /* Configure LED1 GPIO for output */
+
+  stm32_configgpio(GPIO_LED1);
+}
+
+/****************************************************************************
+ * Name: board_autoled_on
+ ****************************************************************************/
+
+void board_autoled_on(int led)
+{
+  if (led == BOARD_LED1)
+    {
+      stm32_gpiowrite(GPIO_LED1, true);
+    }
+}
+
+/****************************************************************************
+ * Name: board_autoled_off
+ ****************************************************************************/
+
+void board_autoled_off(int led)
+{
+  if (led == BOARD_LED1)
+    {
+      stm32_gpiowrite(GPIO_LED1, false);
+    }
+}
+
+#endif /* CONFIG_ARCH_LEDS */
diff --git a/boards/arm/stm32l0/npzero-g1s-dk/src/stm32_boot.c 
b/boards/arm/stm32l0/npzero-g1s-dk/src/stm32_boot.c
new file mode 100644
index 00000000000..2cc3d6f69cf
--- /dev/null
+++ b/boards/arm/stm32l0/npzero-g1s-dk/src/stm32_boot.c
@@ -0,0 +1,79 @@
+/****************************************************************************
+ * boards/arm/stm32l0/npzero-g1s-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 "npzero-g1s-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
+}
+
+/****************************************************************************
+ * 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)
+{
+  /* Perform board-specific initialization */
+
+  stm32_bringup();
+}
+#endif
diff --git a/boards/arm/stm32l0/npzero-g1s-dk/src/stm32_bringup.c 
b/boards/arm/stm32l0/npzero-g1s-dk/src/stm32_bringup.c
new file mode 100644
index 00000000000..c03e8f667e8
--- /dev/null
+++ b/boards/arm/stm32l0/npzero-g1s-dk/src/stm32_bringup.c
@@ -0,0 +1,284 @@
+/****************************************************************************
+ * boards/arm/stm32l0/npzero-g1s-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 <errno.h>
+#include <sys/types.h>
+#include <syslog.h>
+
+#ifdef CONFIG_NPZERO
+#  include <nuttx/i2c/i2c_master.h>
+#  include <nuttx/power/npzero.h>
+#  include "stm32_i2c.h"
+#endif
+
+#ifdef CONFIG_NPZERO_G1S_DK_PMOD_POWER
+#  include <stdbool.h>
+#  include <nuttx/arch.h>
+#  include "stm32_gpio.h"
+#endif
+
+#include "npzero-g1s-dk.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifdef CONFIG_NPZERO_G1S_DK_PMOD_POWER
+/* Half period of the bit-banged I2C clock (about 2 kHz): SDA can take up
+ * to about 100 us to rise while the sensor boards are unpowered.
+ */
+
+#  define PMOD_BB_DELAY     250   /* us */
+
+#  define PMOD_PSWINT       (NPZERO_PSWCTL_PSWINT(3) | \
+                             NPZERO_PSWCTL_PSWINT(4))
+#endif
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+#ifdef CONFIG_NPZERO_G1S_DK_PMOD_POWER
+/****************************************************************************
+ * Name: pmod_scl / pmod_sda
+ *
+ * Description:
+ *   Set the level of SCL or SDA (open drain) and wait a half period.  SCL
+ *   waits for a slave stretching the clock.
+ *
+ ****************************************************************************/
+
+static void pmod_scl(bool high)
+{
+  int n;
+
+  stm32_gpiowrite(GPIO_NPZERO_SCL, high);
+  for (n = 0; high && !stm32_gpioread(GPIO_NPZERO_SCL) && n < 100; n++)
+    {
+      up_udelay(PMOD_BB_DELAY);
+    }
+
+  up_udelay(PMOD_BB_DELAY);
+}
+
+static void pmod_sda(bool high)
+{
+  stm32_gpiowrite(GPIO_NPZERO_SDA, high);
+  up_udelay(PMOD_BB_DELAY);
+}
+
+/****************************************************************************
+ * Name: pmod_start / pmod_stop
+ ****************************************************************************/
+
+static void pmod_start(void)
+{
+  pmod_sda(true);
+  pmod_scl(true);
+  pmod_sda(false);
+  pmod_scl(false);
+}
+
+static void pmod_stop(void)
+{
+  pmod_sda(false);
+  pmod_scl(true);
+  pmod_sda(true);
+}
+
+/****************************************************************************
+ * Name: pmod_write
+ *
+ * Description:
+ *   Send one byte, return true if the slave acknowledged it.
+ *
+ ****************************************************************************/
+
+static bool pmod_write(uint8_t byte)
+{
+  bool ack;
+  int i;
+
+  for (i = 7; i >= 0; i--)
+    {
+      pmod_sda((byte >> i) & 1);
+      pmod_scl(true);
+      pmod_scl(false);
+    }
+
+  pmod_sda(true);
+  pmod_scl(true);
+  ack = !stm32_gpioread(GPIO_NPZERO_SDA);
+  pmod_scl(false);
+  return ack;
+}
+
+/****************************************************************************
+ * Name: pmod_read
+ *
+ * Description:
+ *   Read one byte and answer with a NACK (last byte).
+ *
+ ****************************************************************************/
+
+static uint8_t pmod_read(void)
+{
+  uint8_t byte = 0;
+  int i;
+
+  pmod_sda(true);
+  for (i = 0; i < 8; i++)
+    {
+      pmod_scl(true);
+      byte = (byte << 1) | stm32_gpioread(GPIO_NPZERO_SDA);
+      pmod_scl(false);
+    }
+
+  pmod_scl(true);
+  pmod_scl(false);
+  return byte;
+}
+
+/****************************************************************************
+ * Name: stm32_pmod_power
+ *
+ * Description:
+ *   Enable the power switches of PMOD 3 and 4 in Standby state.  After a
+ *   reset of the nPZero they are off, and an unpowered sensor board slows
+ *   down SDA too much for the STM32 I2C controller, so this is done with a
+ *   slow bit-banged transfer before the I2C driver is initialized.  The
+ *   other fields of PSWCTL (e.g. the host switch mode) are kept.
+ *
+ ****************************************************************************/
+
+static int stm32_pmod_power(void)
+{
+  uint8_t addr = NPZERO_I2C_ADDR << 1;
+  uint8_t pswctl;
+  bool ok;
+
+  stm32_configgpio(GPIO_NPZERO_SCL);
+  stm32_configgpio(GPIO_NPZERO_SDA);
+
+  pmod_start();
+  ok = pmod_write(addr) && pmod_write(NPZERO_PSWCTL);
+  pmod_start();
+  ok = ok && pmod_write(addr | 1);
+  pswctl = ok ? pmod_read() : 0;
+  pmod_stop();
+
+  if (ok && (pswctl & PMOD_PSWINT) != PMOD_PSWINT)
+    {
+      pmod_start();
+      ok = pmod_write(addr) && pmod_write(NPZERO_PSWCTL) &&
+           pmod_write(pswctl | PMOD_PSWINT);
+      pmod_stop();
+
+      /* Let the sensors power up */
+
+      up_mdelay(2);
+    }
+
+  return ok ? OK : -EIO;
+}
+#endif
+
+/****************************************************************************
+ * Name: stm32_npzero_setup
+ *
+ * Description:
+ *   Register the nPZero G1S driver.  The host is powered off while the
+ *   nPZero is in Idle state, so this is done at each wake-up of the host.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NPZERO
+static int stm32_npzero_setup(void)
+{
+  FAR struct i2c_master_s *i2c;
+  int ret;
+
+#ifdef CONFIG_NPZERO_G1S_DK_PMOD_POWER
+  ret = stm32_pmod_power();
+  if (ret < 0)
+    {
+      syslog(LOG_ERR, "ERROR: PMOD power failed: %d\n", ret);
+    }
+#endif
+
+  i2c = stm32_i2cbus_initialize(NPZERO_I2C_BUS);
+  if (i2c == NULL)
+    {
+      return -ENODEV;
+    }
+
+#ifdef CONFIG_I2C_DRIVER
+  ret = i2c_register(i2c, NPZERO_I2C_BUS);
+  if (ret < 0)
+    {
+      syslog(LOG_ERR, "ERROR: i2c_register() failed: %d\n", ret);
+    }
+#endif
+
+  ret = npzero_register(NPZERO_DEVPATH, i2c, NPZERO_I2C_ADDR);
+  if (ret < 0)
+    {
+      syslog(LOG_ERR, "ERROR: npzero_register() failed: %d\n", ret);
+    }
+
+  return ret;
+}
+#endif
+
+/****************************************************************************
+ * 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 = OK;
+
+#ifdef CONFIG_NPZERO
+  /* Register the nPZero G1S driver */
+
+  ret = stm32_npzero_setup();
+#endif
+
+  return ret;
+}

Reply via email to