Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (c) 2024 TOKITA Hiroshi
# SPDX-License-Identifier: Apache-2.0

config SHIELD_SEEED_GROVE_LIS3DHTR
def_bool $(shields_list_contains,seeed_grove_lis3dhtr)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
.. _seeed_grove_3axis_digital_accelerometer:

Seeed Studio Grove 3-Axis Digital Accelerometer
###############################################

Overview
********

The Seeed Studio Grove 3-Axis Digital Accelerometer is a compact sensor module
that provides digital output of 3-axis acceleration.
There are several variations by the measurement range and chip.

.. figure:: img/grove_3axis_digital_accelerometer_lis3dhtr.webp
:align: center
:alt: Grove - 3-Axis Digital Accelerometer (LIS3DHTR)

Grove - 3-Axis Digital Accelerometer (LIS3DHTR) (Credit: Seeed Studio)

These allows for easy integration with Grove connector system.
More information about the Grove connector system can be found at the
`Grove Ecosystem Introduction`_.

Hardware
********

Currently the following models are supported:

- seeed_grove_lis3dhtr: see `Grove - 3-Axis Digital Accelerometer (LIS3DHTR)`_

Programming
***********

Set ``--shield seeed_grove_accel_[sensor_model]`` when you invoke ``west build``.
For example:

.. zephyr-app-commands::
:zephyr-app: samples/sensor/sensor_shell
:board: m5stack_core2/esp32/procpu
:shield: seeed_grove_accel_lis3dhtr
:goals: build

This shield can take a option to tweaking.
Such as connecting bus selection, i2c address, and etc.

.. zephyr-app-commands::
:zephyr-app: samples/sensor/sensor_shell
:board: wio_terminal/samd51p19a
:shield: seeed_grove_accel_lis3dhtr@1:addr=0x18
:goals: build

References
**********

.. target-notes::

.. _Grove Ecosystem Introduction:
https://wiki.seeedstudio.com/Grove_System/

.. _Grove - 3-Axis Digital Accelerometer (LIS3DHTR):
https://wiki.seeedstudio.com/Grove-3-Axis-Digital-Accelerometer-LIS3DHTR/
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Copyright (c) 2024 TOKITA Hiroshi <[email protected]>
* SPDX-License-Identifier: Apache-2.0
*/

/* For convenience, we use the same definitions as LIS3DHTR as the default for this series. */

#include "seeed_grove_accel.overlay"
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (c) 2024 TOKITA Hiroshi <[email protected]>
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/dt-bindings/gpio/gpio.h>
#include <zephyr/dt-bindings/sensor/lis2dh.h>

&SHIELD_CONN_N {
SHIELD_CONVENTIONAL_LABEL(lis3dh): lis3dh@SHIELD_ADDR_HEX {
compatible = "st,lis3dh", "st,lis2dh";
reg = <SHIELD_0X_ADDR>;

#if SHIELD_OPTION_EXISTS(IRQ_GPIO_PIN) || SHIELD_OPTION_EXISTS(IRQ_GPIO_PORT)
irq-gpios = <&SHIELD_OPTION_STRING_UNQUOTED(IRQ_GPIO_PORT)
SHIELD_OPTION(IRQ_GPIO_PIN)
SHIELD_OPTION_STRING_UNQUOTED(IRQ_GPIO_FLAG)>;
#endif
};
};
26 changes: 26 additions & 0 deletions boards/shields/seeed_grove_3axis_digital_accelerometer/shield.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
shield:
name: seeed_grove_accel
full_name: Seeed Studio Grove - 3-Axis Digital Accelerometer
vendor: seeed
variants:
- name: lis3dhtr
full_name: Seeed Studio Grove - 3-Axis Digital Accelerometer (LIS3DHTR)
options:
addr:
default: 0x19
irq-gpio-pin:
type: int
default: 0
irq-gpio-port:
type: string
default: "gpio0"
irq-gpio-flag:
type: string
default: "GPIO_ACTIVE_HIGH"
options:
conn:
type: string
default: "grove_i2c"
addr:
type: int
default: 0x19
86 changes: 64 additions & 22 deletions cmake/modules/shields.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ include(extensions)
# Check that SHIELD has not changed.
zephyr_check_cache(SHIELD WATCH)

set(GEN_SHIELD_DERIVED_OVERLAY_SCRIPT ${ZEPHYR_BASE}/scripts/build/gen_shield_derived_overlay.py)
set(GENERATED_SHIELDS_DIR ${PROJECT_BINARY_DIR}/include/generated/shields)

# Add the directory derived overlay files to the SHIELD_DIRS output variable.
list(APPEND
SHIELD_DIRS
${GENERATED_SHIELDS_DIR}
)

if(SHIELD)
message(STATUS "Shield(s): ${SHIELD}")
endif()
Expand All @@ -44,7 +53,7 @@ if(DEFINED SHIELD)
endif()
# SHIELD-NOTFOUND is a real CMake list, from which valid shields can be popped.
# After processing all shields, only invalid shields will be left in this list.
set(SHIELD-NOTFOUND ${SHIELD_AS_LIST})
string(REGEX REPLACE "([@:][^;]*)" "" SHIELD-NOTFOUND "${SHIELD}")

foreach(root ${BOARD_ROOT})
set(shield_dir ${root}/boards/shields)
Expand Down Expand Up @@ -74,43 +83,76 @@ endforeach()

# Process shields in-order
if(DEFINED SHIELD)
foreach(s ${SHIELD_AS_LIST})
foreach(shld ${SHIELD_AS_LIST})
string(REGEX MATCH [[^([^@:]*)([@:].*)?$]] matched "${shld}")
set(s ${CMAKE_MATCH_1}) # name part
set(shield_opts ${CMAKE_MATCH_2}) # options part

if(NOT ${s} IN_LIST SHIELD_LIST)
continue()
endif()

list(REMOVE_ITEM SHIELD-NOTFOUND ${s})

# Add <shield>.overlay to the shield_dts_files output variable.
list(APPEND
shield_dts_files
${SHIELD_DIR_${s}}/${s}.overlay
)

# Add the shield's directory to the SHIELD_DIRS output variable.
list(APPEND
SHIELD_DIRS
${SHIELD_DIR_${s}}
)

# Search for shield/shield.conf file
if(EXISTS ${SHIELD_DIR_${s}}/${s}.conf)
list(APPEND
shield_conf_files
${SHIELD_DIR_${s}}/${s}.conf
)
endif()

# Add board-specific .conf and .overlay files to their
# respective output variables.
# get board-specific .conf and .overlay filenames
zephyr_file(CONF_FILES ${SHIELD_DIR_${s}}/boards
DTS shield_dts_files
KCONF shield_conf_files
DTS board_overlay_file
KCONF board_conf_file
)

zephyr_file(CONF_FILES ${SHIELD_DIR_${s}}/boards/${s}
DTS shield_dts_files
KCONF shield_conf_files
DTS board_shield_overlay_file
KCONF board_shield_conf_file
)

get_filename_component(board_overlay_stem "${board_overlay_file}" NAME_WE)
get_filename_component(shield_overlay_stem "${board_shield_overlay_file}" NAME_WE)

set(shield_conf_list
"${SHIELD_DIR_${s}}/${s}.conf"
"${board_conf_file}"
"${board_shield_conf_file}")

set(shield_overlay_list
"${SHIELD_DIR_${s}}/${s}.overlay"
"${board_overlay_file}"
"${board_shield_overlay_file}")

set(derived_overlay_list
"${GENERATED_SHIELDS_DIR}/${shld}.overlay"
"${GENERATED_SHIELDS_DIR}/${shld}_${board_overlay_stem}.overlay"
"${GENERATED_SHIELDS_DIR}/${shld}_${board_overlay_stem}_${shield_overlay_stem}.overlay")

# Add board-specific .conf files to the shield_conf_files output variable.
foreach(src_conf ${shield_conf_list})
if(EXISTS ${src_conf})
list(APPEND shield_conf_files ${src_conf})
endif()
endforeach()

foreach(shield_overlay derived_overlay IN ZIP_LISTS shield_overlay_list derived_overlay_list)
if (EXISTS ${shield_overlay})
# Generate a derived overlay for each file, reflecting the options.
execute_process(COMMAND
${PYTHON_EXECUTABLE}
${GEN_SHIELD_DERIVED_OVERLAY_SCRIPT}
"${shield_overlay}"
"--derived-overlay=${derived_overlay}"
"--shield-options=${shield_opts}"
COMMAND_ERROR_IS_FATAL ANY
)

# Add the derived overlay file to the shield_dts_files output variable.
list(APPEND shield_dts_files "${derived_overlay}")
endif()
endforeach()

endforeach()
endif()

Expand Down
Loading
Loading