Skip to content

Commit 2636fd7

Browse files
committed
examples/npzero: add the nPZero G1S power-saving example
Add an example of the nPZero G1S driver for the sensors of the nPZero G1S Development Kit, like the example of the Nanopower driver API: * LIS2DW12 accelerometer on peripheral 3 (SPI), read every 5 s, wakes the host up above about 61 mg on X. * AS6212 temperature sensor on peripheral 4 (I2C), read every 30 s, wakes the host up above 25 C or below 10 C. * Global time-out of 300 s. At each boot of the host it shows the ID and the wake-up reason (with the values of the peripherals and of the ADC that triggered it), sends the configuration and, after CONFIG_EXAMPLES_NPZERO_IDLE_DELAY ms, enters Idle state, which switches the host off. "npzero -s" shows the status only. Both sensors are kept powered while the host is on (pswint): an unpowered AS6212 board blocks the shared I2C bus. Tested on the DevKit with npzero-g1s-dk:nsh: 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 Assisted-by: Claude:claude-opus-5-5
1 parent fdcee82 commit 2636fd7

5 files changed

Lines changed: 508 additions & 0 deletions

File tree

‎examples/npzero/CMakeLists.txt‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# ##############################################################################
2+
# apps/examples/npzero/CMakeLists.txt
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
7+
# license agreements. See the NOTICE file distributed with this work for
8+
# additional information regarding copyright ownership. The ASF licenses this
9+
# file to you under the Apache License, Version 2.0 (the "License"); you may not
10+
# use this file except in compliance with the License. You may obtain a copy of
11+
# the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations under
19+
# the License.
20+
#
21+
# ##############################################################################
22+
23+
if(CONFIG_EXAMPLES_NPZERO)
24+
nuttx_add_application(
25+
NAME
26+
${CONFIG_EXAMPLES_NPZERO_PROGNAME}
27+
SRCS
28+
npzero_main.c
29+
STACKSIZE
30+
${CONFIG_EXAMPLES_NPZERO_STACKSIZE}
31+
PRIORITY
32+
${CONFIG_EXAMPLES_NPZERO_PRIORITY}
33+
MODULE
34+
${CONFIG_EXAMPLES_NPZERO})
35+
endif()

‎examples/npzero/Kconfig‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#
2+
# For a description of the syntax of this configuration file,
3+
# see the file kconfig-language.txt in the NuttX tools repository.
4+
#
5+
6+
config EXAMPLES_NPZERO
7+
tristate "nPZero G1S power-saving IC example"
8+
default n
9+
depends on NPZERO
10+
---help---
11+
Example of the nPZero G1S driver for the nPZero G1S Development
12+
Kit. At each wake-up of the host, it shows the wake-up reason
13+
and the values of the sensors, configures the nPZero to poll the
14+
LIS2DW12 accelerometer (SPI, peripheral 3) and the AS6212
15+
temperature sensor (I2C, peripheral 4) and enters Idle state,
16+
which switches the host off.
17+
18+
if EXAMPLES_NPZERO
19+
20+
config EXAMPLES_NPZERO_PROGNAME
21+
string "Program name"
22+
default "npzero"
23+
---help---
24+
This is the name of the program that will be used when the NSH ELF
25+
program is installed.
26+
27+
config EXAMPLES_NPZERO_PRIORITY
28+
int "nPZero task priority"
29+
default 100
30+
31+
config EXAMPLES_NPZERO_STACKSIZE
32+
int "nPZero stack size"
33+
default DEFAULT_TASK_STACKSIZE
34+
35+
config EXAMPLES_NPZERO_DEVPATH
36+
string "nPZero device path"
37+
default "/dev/npzero0"
38+
39+
config EXAMPLES_NPZERO_IDLE_DELAY
40+
int "Delay before Idle state (ms)"
41+
default 1000
42+
---help---
43+
Time to wait before sending the Idle command, which switches the
44+
host off. It leaves time to connect a debugger to the host.
45+
46+
endif

‎examples/npzero/Make.defs‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
############################################################################
2+
# apps/examples/npzero/Make.defs
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more
7+
# contributor license agreements. See the NOTICE file distributed with
8+
# this work for additional information regarding copyright ownership. The
9+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
10+
# "License"); you may not use this file except in compliance with the
11+
# License. You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations
19+
# under the License.
20+
#
21+
############################################################################
22+
23+
ifneq ($(CONFIG_EXAMPLES_NPZERO),)
24+
CONFIGURED_APPS += $(APPDIR)/examples/npzero
25+
endif

‎examples/npzero/Makefile‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
############################################################################
2+
# apps/examples/npzero/Makefile
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more
7+
# contributor license agreements. See the NOTICE file distributed with
8+
# this work for additional information regarding copyright ownership. The
9+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
10+
# "License"); you may not use this file except in compliance with the
11+
# License. You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations
19+
# under the License.
20+
#
21+
############################################################################
22+
23+
include $(APPDIR)/Make.defs
24+
25+
# nPZero G1S example
26+
27+
PROGNAME = $(CONFIG_EXAMPLES_NPZERO_PROGNAME)
28+
PRIORITY = $(CONFIG_EXAMPLES_NPZERO_PRIORITY)
29+
STACKSIZE = $(CONFIG_EXAMPLES_NPZERO_STACKSIZE)
30+
MODULE = $(CONFIG_EXAMPLES_NPZERO)
31+
32+
MAINSRC = npzero_main.c
33+
34+
include $(APPDIR)/Application.mk

0 commit comments

Comments
 (0)