Skip to content

Commit db33a88

Browse files
authored
Merge pull request #1 from davideq/main
initial release
2 parents e62671d + 27f6c51 commit db33a88

File tree

19 files changed

+20945
-1
lines changed

19 files changed

+20945
-1
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: ISM6HG256X Continuous Integration
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths-ignore:
7+
- '*'
8+
- '**.md'
9+
- '**.txt'
10+
pull_request:
11+
paths-ignore:
12+
- '*'
13+
- '**.md'
14+
- '**.txt'
15+
jobs:
16+
astyle_check:
17+
runs-on: ubuntu-latest
18+
name: AStyle check
19+
steps:
20+
# First of all, clone the repo using the checkout action.
21+
- name: Checkout
22+
uses: actions/checkout@main
23+
24+
- name: Astyle check
25+
id: Astyle
26+
uses: stm32duino/actions/astyle-check@main
27+
28+
# Use the output from the `Astyle` step
29+
- name: Astyle Errors
30+
if: failure()
31+
run: |
32+
cat ${{ steps.Astyle.outputs.astyle-result }}
33+
exit 1
34+
codespell:
35+
name: Check for spelling errors
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@main
40+
41+
# See: https://github.com/codespell-project/actions-codespell/blob/master/README.md
42+
- name: Spell check
43+
uses: codespell-project/actions-codespell@master
44+
with:
45+
check_filenames: true
46+
check_hidden: true
47+
# In the event of a false positive, add the word in all lower case to this file:
48+
ignore_words_file: ./extras/codespell-ignore-words-list.txt
49+
lib_build:
50+
runs-on: ubuntu-latest
51+
name: Library compilation
52+
steps:
53+
54+
# First of all, clone the repo using the checkout action.
55+
- name: Checkout
56+
uses: actions/checkout@main
57+
58+
- name: Compilation
59+
id: compile
60+
uses: stm32duino/actions/compile-examples@main
61+
with:
62+
board-pattern: "NUCLEO_L476RG"
63+
64+
# Use the output from the `Compilation` step
65+
- name: Compilation Errors
66+
if: failure()
67+
run: |
68+
cat ${{ steps.compile.outputs.compile-result }}
69+
exit 1

README.md

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,65 @@
11
# ISM6HG256X
2-
Arduino library to support the ISM6HG256X Intelligent IMU with simultaneous low-g and high-g acceleration detection
2+
Arduino library to support the ISM6HG256X.
3+
4+
## API
5+
6+
This sensor uses I2C or SPI to communicate.
7+
For I2C it is then required to create a TwoWire interface before accessing to the sensors:
8+
9+
TwoWire dev_i2c(I2C_SDA, I2C_SCL);
10+
dev_i2c.begin();
11+
12+
For SPI it is then required to create a SPI interface before accessing to the sensors:
13+
14+
SPIClass dev_spi(SPI_MOSI, SPI_MISO, SPI_SCK);
15+
dev_spi.begin();
16+
17+
An instance can be created and enabled when the I2C bus is used following the procedure below:
18+
19+
ISM6HG256XSensor sensor(&dev_i2c);
20+
sensor.begin();
21+
sensor.Enable_X();
22+
sensor.Enable_G();
23+
24+
An instance can be created and enabled when the SPI bus is used following the procedure below:
25+
26+
ISM6HG256XSensor sensor(&dev_spi, CS_PIN);
27+
sensor.begin();
28+
sensor.Enable_X();
29+
sensor.Enable_G();
30+
31+
The access to the sensor values is done as explained below:
32+
33+
ISM6HG256X_Axes_t accel, angrate;
34+
sensor.Get_X_Axes(accel);
35+
sensor.Get_G_Axes(&angrate);
36+
37+
## Examples
38+
39+
* ISM6HG256X_DataLog_Terminal: This application shows how to get data from ISM6HG256X and print them on terminal.
40+
41+
* ISM6HG256X_6D_Orientation: This application shows how to use ISM6HG256X to find out the 6D orientation and display data on a hyperterminal.
42+
43+
* ISM6HG256X_Double_Tap_Detection: This application shows how to detect the double tap event using the ISM6HG256X.
44+
45+
* ISM6HG256X_FIFO_Polling: This application shows how to get data from FIFO in pooling mode and print them on terminal.
46+
47+
* ISM6HG256X_FIFO_Interrupt: This application shows how to get data from FIFO using interrupt and print them on terminal.
48+
49+
* ISM6HG256X_Free_Fall_Detection: This application shows how to detect the free fall event using the ISM6HG256X.
50+
51+
* ISM6HG256X_Pedometer: This application shows how to use ISM6HG256X to count steps.
52+
53+
* ISM6HG256X_Single_Tap_Detection: This application shows how to detect the single tap event using the ISM6HG256X.
54+
55+
* ISM6HG256X_Tilt_Detection: This application shows how to detect the tilt event using the ISM6HG256X.
56+
57+
* ISM6HG256X_Wake_Up_Detection: This application shows how to detect the wake-up event using the ISM6HG256X.
58+
59+
## Documentation
60+
61+
You can find the source files at
62+
https://github.com/stm32duino/ISM6HG256X
63+
64+
The ISM6HG256X datasheet is available at
65+
https://www.st.com/content/st_com/en/products/mems-and-sensors/accelerometers/ISM6HG256X.html
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
/*
2+
@file ISM6HG256X_HelloWorld.ino
3+
@author STMicroelectronics
4+
@brief Example to use the ISM6HG256X6D Orientation
5+
*******************************************************************************
6+
Copyright (c) 2025, STMicroelectronics
7+
All rights reserved.
8+
This software component is licensed by ST under BSD 3-Clause license,
9+
the "License"; You may not use this file except in compliance with the
10+
License. You may obtain a copy of the License at:
11+
opensource.org/licenses/BSD-3-Clause
12+
*******************************************************************************
13+
*/
14+
#include <ISM6HG256XSensor.h>
15+
16+
#define INT1_pin 5
17+
18+
ISM6HG256XSensor ISM6HG256X(&Wire);
19+
//Interrupts.
20+
volatile int mems_event = 0;
21+
22+
char report[256];
23+
24+
void INT1Event_cb();
25+
void sendOrientation();
26+
27+
void setup()
28+
{
29+
30+
// Initlialize serial.
31+
Serial.begin(115200);
32+
delay(1000);
33+
34+
// Initlialize Led.
35+
pinMode(LED_BUILTIN, OUTPUT);
36+
37+
// Initlialize i2c.
38+
Wire.begin();
39+
40+
// Enable INT1 pin.
41+
attachInterrupt(INT1_pin, INT1Event_cb, RISING);
42+
43+
// Initlialize components.
44+
ISM6HG256X.begin();
45+
ISM6HG256X.Enable_X();
46+
47+
// Enable 6D Orientation.
48+
ISM6HG256X.Enable_6D_Orientation(ISM6HG256X_INT1_PIN);
49+
}
50+
51+
void loop()
52+
{
53+
if (mems_event) {
54+
mems_event = 0;
55+
ISM6HG256X_Event_Status_t status;
56+
ISM6HG256X.Get_X_Event_Status(&status);
57+
58+
if (status.D6DOrientationStatus) {
59+
// Send 6D Orientation
60+
sendOrientation();
61+
62+
// Led blinking.
63+
digitalWrite(LED_BUILTIN, HIGH);
64+
delay(100);
65+
digitalWrite(LED_BUILTIN, LOW);
66+
}
67+
}
68+
}
69+
70+
void INT1Event_cb()
71+
{
72+
mems_event = 1;
73+
}
74+
75+
void sendOrientation()
76+
{
77+
uint8_t xl = 0;
78+
uint8_t xh = 0;
79+
uint8_t yl = 0;
80+
uint8_t yh = 0;
81+
uint8_t zl = 0;
82+
uint8_t zh = 0;
83+
84+
ISM6HG256X.Get_6D_Orientation_XL(&xl);
85+
ISM6HG256X.Get_6D_Orientation_XH(&xh);
86+
ISM6HG256X.Get_6D_Orientation_YL(&yl);
87+
ISM6HG256X.Get_6D_Orientation_YH(&yh);
88+
ISM6HG256X.Get_6D_Orientation_ZL(&zl);
89+
ISM6HG256X.Get_6D_Orientation_ZH(&zh);
90+
91+
if (xl == 0 && yl == 0 && zl == 0 && xh == 0 && yh == 1 && zh == 0) {
92+
sprintf(report, "\r\n ________________ " \
93+
"\r\n | | " \
94+
"\r\n | * | " \
95+
"\r\n | | " \
96+
"\r\n | | " \
97+
"\r\n | | " \
98+
"\r\n | | " \
99+
"\r\n |________________| \r\n");
100+
}
101+
102+
else if (xl == 1 && yl == 0 && zl == 0 && xh == 0 && yh == 0 && zh == 0) {
103+
sprintf(report, "\r\n ________________ " \
104+
"\r\n | | " \
105+
"\r\n | * | " \
106+
"\r\n | | " \
107+
"\r\n | | " \
108+
"\r\n | | " \
109+
"\r\n | | " \
110+
"\r\n |________________| \r\n");
111+
}
112+
113+
else if (xl == 0 && yl == 0 && zl == 0 && xh == 1 && yh == 0 && zh == 0) {
114+
sprintf(report, "\r\n ________________ " \
115+
"\r\n | | " \
116+
"\r\n | | " \
117+
"\r\n | | " \
118+
"\r\n | | " \
119+
"\r\n | | " \
120+
"\r\n | * | " \
121+
"\r\n |________________| \r\n");
122+
}
123+
124+
else if (xl == 0 && yl == 1 && zl == 0 && xh == 0 && yh == 0 && zh == 0) {
125+
sprintf(report, "\r\n ________________ " \
126+
"\r\n | | " \
127+
"\r\n | | " \
128+
"\r\n | | " \
129+
"\r\n | | " \
130+
"\r\n | | " \
131+
"\r\n | * | " \
132+
"\r\n |________________| \r\n");
133+
}
134+
135+
else if (xl == 0 && yl == 0 && zl == 0 && xh == 0 && yh == 0 && zh == 1) {
136+
sprintf(report, "\r\n __*_____________ " \
137+
"\r\n |________________| \r\n");
138+
}
139+
140+
else if (xl == 0 && yl == 0 && zl == 1 && xh == 0 && yh == 0 && zh == 0) {
141+
sprintf(report, "\r\n ________________ " \
142+
"\r\n |________________| " \
143+
"\r\n * \r\n");
144+
}
145+
146+
else {
147+
sprintf(report, "None of the 6D orientation axes is set in accelerometer.\r\n");
148+
}
149+
150+
Serial.print(report);
151+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
@file ISM6HG256X_DataLog_Terminal.ino
3+
@author STMicroelectornics
4+
@brief Example to use the ISM6HG256X inertial measurement sensor
5+
*******************************************************************************
6+
Copyright (c) 2025, STMicroelectronics
7+
All rights reserved.
8+
This software component is licensed by ST under BSD 3-Clause license,
9+
the "License"; You may not use this file except in compliance with the
10+
License. You may obtain a copy of the License at:
11+
opensource.org/licenses/BSD-3-Clause
12+
*******************************************************************************
13+
*/
14+
15+
#include <ISM6HG256XSensor.h>
16+
17+
ISM6HG256XSensor sensor(&Wire);
18+
ISM6HG256X_Axes_t accel, angrate;
19+
20+
void setup()
21+
{
22+
pinMode(LED_BUILTIN, OUTPUT);
23+
Serial.begin(115200);
24+
Wire.begin();
25+
sensor.begin();
26+
sensor.Enable_X();
27+
sensor.Enable_G();
28+
}
29+
30+
void loop()
31+
{
32+
sensor.Get_X_Axes(&accel);
33+
sensor.Get_G_Axes(&angrate);
34+
35+
Serial.print("Accel-X[mg]:");
36+
Serial.print(accel.x);
37+
Serial.print(",Accel-Y[mg]:");
38+
Serial.print(accel.y);
39+
Serial.print(",Accel-Z[mg]:");
40+
Serial.print(accel.z);
41+
42+
Serial.print(",AngRate-X[mdps]:");
43+
Serial.print(angrate.x);
44+
Serial.print(",AngRate-Y[mdps]:");
45+
Serial.print(angrate.y);
46+
Serial.print(",AngRate-Z[mdps]:");
47+
Serial.println(angrate.z);
48+
49+
blink(LED_BUILTIN);
50+
}
51+
52+
inline void blink(int pin)
53+
{
54+
digitalWrite(pin, HIGH);
55+
delay(25);
56+
digitalWrite(pin, LOW);
57+
delay(975);
58+
}

0 commit comments

Comments
 (0)