1.. zephyr:code-sample:: tdk_apex 2 :name: TDK Advanced Pedometer and Event Detection (APEX) 3 :relevant-api: sensor_interface 4 5 Get TDK APEX event detection (trigger mode). 6 7Overview 8******** 9 10This sample application shows how to use the APEX (Advanced Pedometer 11and Event Detection) features of TDK Invensense sensors. It consists of: 12** Pedometer: Tracks step count, and provide details such as the cadence 13and the estimated activity type (Walk, Run, Unknown). 14** Tilt Detection: Detects the Tilt when tilting the board with an angle 15of 30 degrees or more. The tilt event is generated when the 16position is held for 4 seconds. 17** Wake on Motion (WoM): Detects motion per axis exceeding 195 mg threshold. 18** Significant Motion Detector (SMD): Detects when the user has moved 19significantly. 20APEX features support are configured through devicetree. 21 22References 23********** 24 25 - https://invensense.tdk.com/download-pdf/an-000271-icm-42607x-and-icm-42670x-apex-motion-functions-description-and-usage/ 26 27Driver configuration 28******************** 29 30The APEX is based on accelerometer data only. The TDK Sensor driver configures 31accelerometer low power mode and the APEX operating frequency (25Hz or 50Hz). 32 33Wiring 34******* 35 36This sample uses an external breakout for the sensor. A devicetree 37overlay must be provided to identify the TDK sensor, the SPI or I2C bus interface and the interrupt 38sensor GPIO. 39 40Building and Running 41******************** 42 43This sample supports TDK IMU devices. Each device needs 44to be aliased as ``tdk-apex-sensorN`` where ``N`` goes from ``0`` to ``9``. For example: 45 46.. code-block:: devicetree 47 48 / { 49 aliases { 50 tdk-apex-sensor0 = &icm42670p; 51 }; 52 }; 53 54This sample supports APEX feature of TDK device. It needs to be specified as bellow: 55 56.. code-block:: devicetree 57 58 icm42670p: icm42670p@0 { 59 apex = "pedometer"; 60 } 61 62Make sure the apex feature used is in devicetree, then build and run with: 63 64.. zephyr-app-commands:: 65 :zephyr-app: samples/sensor/tdk_apex 66 :board: nrf52dk/nrf52832 67 :goals: build flash 68 69Sample Output 70============= 71 72.. code-block:: devicetree 73 74 icm42670p: icm42670p@0 { 75 apex = "pedometer"; 76 } 77 78.. code-block:: console 79 80 Found device "icm42670p@68", getting sensor data 81 [0:00:09.287]: STEP_DET count: 6 steps cadence: 2.0 steps/s activity: Unknown 82 [0:00:09.689]: STEP_DET count: 7 steps cadence: 2.1 steps/s activity: Walk 83 [0:00:10.051]: STEP_DET count: 8 steps cadence: 2.2 steps/s activity: Walk 84 [0:00:10.433]: STEP_DET count: 9 steps cadence: 2.2 steps/s activity: Walk 85 [0:00:10.835]: STEP_DET count: 10 steps cadence: 2.3 steps/s activity: Walk 86 87 <repeats endlessly> 88 89.. code-block:: devicetree 90 91 icm42670p: icm42670p@0 { 92 apex = "tilt"; 93 } 94 95.. code-block:: console 96 97 Found device "icm42670p@68", getting sensor data 98 [0:00:15.249]: TILT 99 [0:00:21.479]: TILT 100 [0:00:26.765]: TILT 101 102 <repeats endlessly> 103 104.. code-block:: devicetree 105 106 icm42670p: icm42670p@0 { 107 apex = "wom"; 108 } 109 110.. code-block:: console 111 112 Found device "icm42670p@68", getting sensor data 113 [0:00:02.555]: WOM x=1 y=0 z=1 114 [0:00:02.636]: WOM x=0 y=0 z=1 115 [0:00:02.797]: WOM x=0 y=1 z=0 116 [0:00:02.877]: WOM x=0 y=0 z=1 117 [0:00:02.957]: WOM x=1 y=1 z=1 118 119 <repeats endlessly> 120 121.. code-block:: devicetree 122 123 icm42670p: icm42670p@0 { 124 apex = "smd"; 125 } 126 127.. code-block:: console 128 129 Found device "icm42670@68", getting sensor data 130 [0:00:04.622]: SMD 131 [0:00:05.084]: SMD 132 [0:00:05.566]: SMD 133 134 <repeats endlessly> 135