Skip to content

Commit 43faa50

Browse files
authored
Merge pull request #16 from jerabaul29/feat/FIFO_read_raw
Add methods to read raw ACC and GYR data from FIFO
2 parents 4be6161 + 9c5cd65 commit 43faa50

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=STM32duino ISM330DHCX
2-
version=2.1.1
2+
version=2.1.2
33
author=SRA
44
maintainer=stm32duino
55
sentence=High-Performance 3D digital accelerometer and 3D digital gyroscope.

src/ISM330DHCXSensor.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2177,6 +2177,26 @@ ISM330DHCXStatusTypeDef ISM330DHCXSensor::FIFO_ACC_Get_Axes(int32_t *Acceleratio
21772177
return ISM330DHCX_OK;
21782178
}
21792179

2180+
/**
2181+
* @brief Get the ISM330DHCX FIFO accelero single sample (16-bit data per 3 axes) raw data
2182+
* @param Acceleration FIFO accelerometer raw axes reading
2183+
* @retval 0 in case of success, an error code otherwise
2184+
*/
2185+
ISM330DHCXStatusTypeDef ISM330DHCXSensor::FIFO_ACC_Get_AxesRaw(int16_t *AccelerationRaw)
2186+
{
2187+
uint8_t data[6];
2188+
2189+
if (FIFO_Get_Data(data) != ISM330DHCX_OK) {
2190+
return ISM330DHCX_ERROR;
2191+
}
2192+
2193+
AccelerationRaw[0] = ((int16_t)data[1] << 8) | data[0];
2194+
AccelerationRaw[1] = ((int16_t)data[3] << 8) | data[2];
2195+
AccelerationRaw[2] = ((int16_t)data[5] << 8) | data[4];
2196+
2197+
return ISM330DHCX_OK;
2198+
}
2199+
21802200
/**
21812201
* @brief Get the ISM330DHCX FIFO gyro single sample (16-bit data per 3 axes) and calculate angular velocity [mDPS]
21822202
* @param AngularVelocity FIFO gyroscope axes [mDPS]
@@ -2212,6 +2232,26 @@ ISM330DHCXStatusTypeDef ISM330DHCXSensor::FIFO_GYRO_Get_Axes(int32_t *AngularVel
22122232
return ISM330DHCX_OK;
22132233
}
22142234

2235+
/**
2236+
* @brief Get the ISM330DHCX FIFO gyro single sample (16-bit data per 3 axes) raw data
2237+
* @param AngularVelocity FIFO gyroscope raw axes reading
2238+
* @retval 0 in case of success, an error code otherwise
2239+
*/
2240+
ISM330DHCXStatusTypeDef ISM330DHCXSensor::FIFO_GYRO_Get_AxesRaw(int16_t *AngularVelocityRaw)
2241+
{
2242+
uint8_t data[6];
2243+
2244+
if (FIFO_Get_Data(data) != ISM330DHCX_OK) {
2245+
return ISM330DHCX_ERROR;
2246+
}
2247+
2248+
AngularVelocityRaw[0] = ((int16_t)data[1] << 8) | data[0];
2249+
AngularVelocityRaw[1] = ((int16_t)data[3] << 8) | data[2];
2250+
AngularVelocityRaw[2] = ((int16_t)data[5] << 8) | data[4];
2251+
2252+
return ISM330DHCX_OK;
2253+
}
2254+
22152255
/**
22162256
* @brief Enable ISM330DHCX accelerometer DRDY interrupt on INT1
22172257
* @retval 0 in case of success, an error code otherwise

src/ISM330DHCXSensor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ class ISM330DHCXSensor {
152152
ISM330DHCXStatusTypeDef FIFO_Get_Tag(uint8_t *Tag);
153153
ISM330DHCXStatusTypeDef FIFO_Get_Data(uint8_t *Data);
154154
ISM330DHCXStatusTypeDef FIFO_ACC_Get_Axes(int32_t *Acceleration);
155+
ISM330DHCXStatusTypeDef FIFO_ACC_Get_AxesRaw(int16_t *AccelerationRaw);
155156
ISM330DHCXStatusTypeDef FIFO_GYRO_Get_Axes(int32_t *AngularVelocity);
157+
ISM330DHCXStatusTypeDef FIFO_GYRO_Get_AxesRaw(int16_t *AngularVelocityRaw);
156158

157159
ISM330DHCXStatusTypeDef ACC_Enable_DRDY_On_INT1();
158160
ISM330DHCXStatusTypeDef ACC_Disable_DRDY_On_INT1();

0 commit comments

Comments
 (0)