Skip to content
Merged
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
7 changes: 5 additions & 2 deletions .github/workflows/Continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,14 @@ jobs:
id: compile
uses: stm32duino/actions/compile-examples@main
with:
board-pattern: "NUCLEO_L476RG"

custom-config: "./extras/build_config.json"
board-pattern: "NUCLEO_L476RG|NUCLEO_H503RB|NUCLEO_C562RE"
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
# Use the output from the `Compilation` step
- name: Compilation Errors
if: failure()
run: |
cat ${{ steps.compile.outputs.compile-result }}
exit 1

48 changes: 35 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@ An instance can be created and enabled when the SPI bus is used following the pr
Accelero.begin();
Accelero.Enable_X();

An instance can be created and enabled when the I3C bus is used with SETDASA (static-to-dynamic address assignment):
LIS2DUXS12Sensor Accelero(&I3C, LIS2DUXS12_I3C_ADD_H);
I3C.resetDynamicAddresses();
I3C.assignDynamicAddress(Accelero.getStaticAddress(), LIS2DUXS12_DYNAMIC_ADDRESS);
Accelero.begin(LIS2DUXS12_DYNAMIC_ADDRESS);
I3C.setClock(12500000);
Accelero.Enable_X();

An instance can be created and enabled when the I3C bus is used with ENTDAA (dynamic address discovery):

LIS2DUXS12Sensor Accelero(&I3C);
I3C.begin(I3C_SDA, I3C_SCL, 1000000U);
I3C.discover(devices, 8, &found);
// find dynAddr by matching LIS2DUXS12_I3C_PID_H in discovered devices
Accelero.begin(dynAddr);
I3C.setClock(12500000);
Accelero.Enable_X();

The access to the sensor values is done as explained below:

Read accelerometer.
Expand All @@ -35,31 +53,35 @@ The access to the sensor values is done as explained below:

## Examples

* LIS2DUXS12_DataLog_Terminal: This application shows how to get data from LIS2DUXS12 accelerometer and print them on terminal.
* LIS2DUXS12_DataLog_Terminal_I2C: This application shows how to get data from LIS2DUXS12 accelerometer and print them on terminal over I2C.

* LIS2DUXS12_Datalog_Terminal_I3C: This application shows how to use LIS2DUXS12 accelerometer over I3C using SETDASA.

* LIS2DUXS12_Datalog_Terminal_I3C_ENTDAA: This application shows how to discover and use LIS2DUXS12 dynamic address over I3C.

* LIS2DUXS12_6D_Orientation: This application shows how to use LIS2DUXS12 accelerometer to find out the 6D orientation and display data on a hyperterminal.
* LIS2DUXS12_6D_Orientation_I2C: This application shows how to use LIS2DUXS12 accelerometer to find out the 6D orientation and display data on a hyperterminal.

* LIS2DUXS12_Double_Tap_Detection: This application shows how to detect the double tap event using the LIS2DUXS12 accelerometer.
* LIS2DUXS12_Double_Tap_Detection_I2C: This application shows how to detect the double tap event using the LIS2DUXS12 accelerometer.

* LIS2DUXS12_FIFO_Polling: This application shows how to get accelerometer data from FIFO in pooling mode and print them on terminal.
* LIS2DUXS12_FIFO_Polling_I2C: This application shows how to get accelerometer data from FIFO in pooling mode and print them on terminal.

* LIS2DUXS12_FIFO_Interrupt: This application shows how to get accelerometer data from FIFO using interrupt and print them on terminal.
* LIS2DUXS12_FIFO_Interrupt_I2C: This application shows how to get accelerometer data from FIFO using interrupt and print them on terminal.

* LIS2DUXS12_Free_Fall_Detection: This application shows how to detect the free fall event using the LIS2DUXS12 accelerometer.
* LIS2DUXS12_Free_Fall_Detection_I2C: This application shows how to detect the free fall event using the LIS2DUXS12 accelerometer.

* LIS2DUXS12_MLC: This application shows how to detect the activity using the LIS2DUXS12 Machine Learning Core.
* LIS2DUXS12_MLC_I2C: This application shows how to detect the activity using the LIS2DUXS12 Machine Learning Core.

* LIS2DUXS12_Pedometer: This application shows how to use LIS2DUXS12 accelerometer to count steps.
* LIS2DUXS12_Pedometer_I2C: This application shows how to use LIS2DUXS12 accelerometer to count steps.

* LIS2DUXS12_Qvar_Polling: This application shows how to use LIS2DUXS12 Qvar features in polling mode.
* LIS2DUXS12_Qvar_Polling_I2C: This application shows how to use LIS2DUXS12 Qvar features in polling mode.

* LIS2DUXS12_Single_Tap_Detection: This application shows how to detect the single tap event using the LIS2DUXS12 accelerometer.
* LIS2DUXS12_Single_Tap_Detection_I2C: This application shows how to detect the single tap event using the LIS2DUXS12 accelerometer.

* LIS2DUXS12_Tilt_Detection: This application shows how to detect the tilt event using the LIS2DUXS12 accelerometer.
* LIS2DUXS12_Tilt_Detection_I2C: This application shows how to detect the tilt event using the LIS2DUXS12 accelerometer.

* LIS2DUXS12_Triple_Tap_Detection: This application shows how to detect the triple tap event using the LIS2DUXS12 accelerometer.
* LIS2DUXS12_Triple_Tap_Detection_I2C: This application shows how to detect the triple tap event using the LIS2DUXS12 accelerometer.

* LIS2DUXS12_Wake_Up_Detection: This application shows how to detect the wake-up event using the LIS2DUXS12 accelerometer.
* LIS2DUXS12_Wake_Up_Detection_I2C: This application shows how to detect the wake-up event using the LIS2DUXS12 accelerometer.

## Documentation

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
@file LIS2DUXS12_6D_Orientation.ino
@file LIS2DUXS12_6D_Orientation_I2C.ino
@author STMicroelectronics
@brief Example to use the LIS2DUXS12 6D Orientation
*******************************************************************************
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
@file LIS2DUXS12_DataLog_Terminal.ino
@file LIS2DUXS12_DataLog_Terminal_I2C.ino
@author STMicroelectronics
@brief Example to use the LIS2DUXS12 inertial measurement sensor
*******************************************************************************
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
@file LIS2DUXS12_DataLog_Terminal_I3C.ino
@author STMicroelectronics
@brief Example to use the LIS2DUXS12 sensor with I3C and SETDASA command
*******************************************************************************
Copyright (c) 2026, STMicroelectronics
All rights reserved.

This software component is licensed by ST under BSD 3-Clause license,
the "License"; You may not use this file except in compliance with the
License. You may obtain a copy of the License at:
opensource.org/licenses/BSD-3-Clause

*******************************************************************************
*/
#include "LIS2DUXS12Sensor.h"

#define LIS2DUXS12_DYNAMIC_ADDRESS 0x30

LIS2DUXS12Sensor sensor(&I3C, LIS2DUXS12_I3C_ADD_H);

void setup()
{
Serial.begin(115200);
while (!Serial) {}
delay(1000);

Serial.println("=== LIS2DUXS12 SETDASA ===");

if (!I3C.begin(I3C_SDA, I3C_SCL, 1000000U)) {
Serial.println("begin() failed");
while (1) {}
}

if (!I3C.resetDynamicAddresses()) {
Serial.println("resetDynamicAddresses() failed");
while (1) {}
}
if (!I3C.assignDynamicAddress(sensor.getStaticAddress(), LIS2DUXS12_DYNAMIC_ADDRESS)) {
Serial.println("assignDynamicAddress() failed");
while (1) {}
}

if (sensor.begin(LIS2DUXS12_DYNAMIC_ADDRESS) != LIS2DUXS12_STATUS_OK) {
Serial.println("sensor.begin() failed");
while (1) {}
}

if (!I3C.setClock(12500000)) {
Serial.println("setClock() failed");
while (1) {}
}

if (sensor.Enable_X() != LIS2DUXS12_STATUS_OK) {
Serial.println("sensor.Enable_X() failed");
while (1) {}
}

Serial.println("LIS2DUXS12 ready");
}

void loop()
{
int32_t accel[3] = {0};

if (sensor.Get_X_Axes(accel) == LIS2DUXS12_STATUS_OK) {
Serial.print("Accel-X[mg]:");
Serial.print(accel[0]);
Serial.print(",Accel-Y[mg]:");
Serial.print(accel[1]);
Serial.print(",Accel-Z[mg]:");
Serial.println(accel[2]);
} else {
Serial.println("Read failed");
}

delay(500);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
@file LIS2DUXS12_DataLog_Terminal_I3C_ENTDAA.ino
@author STMicroelectronics
@brief Example to use the LIS2DUXS12 sensor with I3C dynamic address assignment
*******************************************************************************
Copyright (c) 2026, STMicroelectronics
All rights reserved.

This software component is licensed by ST under BSD 3-Clause license,
the "License"; You may not use this file except in compliance with the
License. You may obtain a copy of the License at:
opensource.org/licenses/BSD-3-Clause

*******************************************************************************
*/

#include "LIS2DUXS12Sensor.h"

LIS2DUXS12Sensor sensor(&I3C);

void setup()
{
Serial.begin(115200);
while (!Serial) {}
delay(1000);

Serial.println("=== LIS2DUXS12 DAA ===");

if (!I3C.begin(I3C_SDA, I3C_SCL, 1000000U)) {
Serial.println("begin() failed");
while (1) {}
}

if (!I3C.resetDynamicAddresses()) {
Serial.println("resetDynamicAddresses() failed");
while (1) {}
}

if (!I3C.isI3CDeviceReady(0x19)) {
Serial.println("isI3CDeviceReady() failed");
while (1) {}
}

I3CDiscoveredDevice devices[8] = {};
size_t found = 0;

if (I3C.discover(devices, 8, &found)) {
Serial.println("discover() failed");
while (1) {}
}

uint8_t lisDynAddr = 0U;

for (size_t i = 0; i < found; ++i) {
Serial.println(devices[i].pid, HEX);
if (devices[i].pid == LIS2DUXS12_I3C_PID_H) {
lisDynAddr = devices[i].dynAddr;
Serial.print("lisDynAddr=");
Serial.println(lisDynAddr, HEX);
break;
}
}

if (lisDynAddr == 0U) {
Serial.println("Sensor not found");
while (1) {}
}

if (sensor.begin(lisDynAddr) != LIS2DUXS12_STATUS_OK) {
Serial.println("sensor.begin() failed");
while (1) {}
}

if (!I3C.setClock(12500000)) {
Serial.println("setClock() failed");
while (1) {}
}

if (sensor.Enable_X() != LIS2DUXS12_STATUS_OK) {
Serial.println("sensor.Enable_X() failed");
while (1) {}
}
Serial.println("LIS2DUXS12 ready");
}

void loop()
{
int32_t accel[3] = {0};
int32_t angrate[3] = {0};

if (sensor.Get_X_Axes(accel) == LIS2DUXS12_STATUS_OK) {
Serial.print("Accel-X[mg]:");
Serial.print(accel[0]);
Serial.print(",Accel-Y[mg]:");
Serial.print(accel[1]);
Serial.print(",Accel-Z[mg]:");
Serial.println(accel[2]);
} else {
Serial.println("Read failed");
}

delay(500);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
@file LIS2DUXS12_Double_Tap_Detection.ino
@file LIS2DUXS12_Double_Tap_Detection_I2C.ino
@author STMicroelectronics
@brief Example to use the LIS2DUXS12 Double Tap Detection
*******************************************************************************
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
@file LIS2DUXS12_FIFO_Interrupt.ino
@file LIS2DUXS12_FIFO_Interrupt_I2C.ino
@author STMicroelectronics
@brief Example to use the LIS2DUXS12 library with FIFO status interrupts.
*******************************************************************************
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
@file LIS2DUXS12_FIFO_Polling.ino
@file LIS2DUXS12_FIFO_Polling_I2C.ino
@author STMicroelectronics
@brief Example to use the LIS2DUXS12 library with FIFO status in polling mode.
*******************************************************************************
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
@file LIS2DUXS12_Free_Fall_Detection.ino
@file LIS2DUXS12_Free_Fall_Detection_I2C.ino
@author STMicroelectronics
@brief Example to use the LIS2DUXS12 Free Fall Detection
*******************************************************************************
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
@file LIS2DUXS12_MLC.ino
@file LIS2DUXS12_MLC_I2C.ino
@author STMicroelectronics
@brief Example to use the LIS2DUXS12 Machine Learning Core
*******************************************************************************
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
@file LIS2DUXS12_Pedometer.ino
@file LIS2DUXS12_Pedometer_I2C.ino
@author STMicroelectronics
@brief Example to use the LIS2DUXS12 Pedometer
*******************************************************************************
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
@file LIS2DUXS12_Qvar.ino
@file LIS2DUXS12_Qvar_Polling_I2C.ino
@author STMicroelectronics
@brief Example to use LIS2DUXS12 Qvar features
*******************************************************************************
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
@file LIS2DUXS12_Single_Tap_Detection.ino
@file LIS2DUXS12_Single_Tap_Detection_I2C.ino
@author STMicroelectronics
@brief Example to use the LIS2DUXS12 Single Tap Detection
*******************************************************************************
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
@file LIS2DUXS12_Tilt_Detection.ino
@file LIS2DUXS12_Tilt_Detection_I2C.ino
@author STMicroelectronics
@brief Example to use the LIS2DUXS12 Tilt Detection
*******************************************************************************
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
@file LIS2DUXS12_Triple_Tap_Detection.ino
@file LIS2DUXS12_Triple_Tap_Detection_I2C.ino
@author STMicroelectronics
@brief Example to use the LIS2DUXS12 Triple Tap Detection
*******************************************************************************
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
@file LIS2DUXS12_Wake_Up_Detection.ino
@file LIS2DUXS12_Wake_Up_Detection_I2C.ino
@author STMicroelectronics
@brief Example to use the LIS2DUXS12 Wake Up Detection
*******************************************************************************
Expand Down
26 changes: 26 additions & 0 deletions extras/build_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"cores": [
{
"maintainer": "STMicroelectronics",
"architecture": "stm32",
"boards": [
],
"sketches": [
{
"pattern": "[^I][^3][^C]",
"applicable": true,
"boards": [
"NUCLEO_L476RG",
"NUCLEO_H503RB",
"NUCLEO_C562RE"
]
},
{
"pattern": "I3C",
"applicable": true,
"boards": [ "NUCLEO_H503RB","NUCLEO_C562RE"]
}
]
}
]
}
3 changes: 2 additions & 1 deletion extras/codespell-ignore-words-list.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ois
ois
daa
Loading