Skip to content

Commit 53062a5

Browse files
committed
2 parents f430202 + 1707188 commit 53062a5

File tree

2 files changed

+49
-17
lines changed

2 files changed

+49
-17
lines changed

src/sfe_ism330dhcx.cpp

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -934,12 +934,20 @@ bool QwDevISM330DHCX::setFifoTimestampDec(uint8_t val)
934934
// openDrain Set true for active low and false for active high
935935
//
936936

937-
bool QwDevISM330DHCX::setPinMode(bool openDrain )
937+
bool QwDevISM330DHCX::setPinMode(bool activeLow )
938938
{
939939
int32_t retVal;
940940

941-
//0 = push-pull, active high, 1 = open-drain, active low
942-
retVal = ism330dhcx_pin_mode_set(&sfe_dev, (ism330dhcx_pp_od_t)openDrain);
941+
//0 = active high : active low, 1
942+
retVal = ism330dhcx_pin_polarity_set(&sfe_dev, (ism330dhcx_h_lactive_t)activeLow);
943+
944+
if( retVal != 0 )
945+
return false;
946+
947+
if( activeLow )
948+
// pinmode must be set to push-pull when active low is set.
949+
// See section 9.14 on pg 51 of datasheet for more information
950+
retVal = ism330dhcx_pin_mode_set(&sfe_dev, (ism330dhcx_pp_od_t)0);
943951

944952
if( retVal != 0 )
945953
return false;
@@ -981,13 +989,19 @@ bool QwDevISM330DHCX::setIntNotification(uint8_t val)
981989
// Sends the accelerometer's data ready signal to interrupt one.
982990
//
983991

984-
bool QwDevISM330DHCX::setAccelStatustoInt1()
992+
bool QwDevISM330DHCX::setAccelStatustoInt1(bool enable)
985993
{
986994

987995
int32_t retVal;
988996

989-
ism330dhcx_pin_int1_route_t int1_route;
990-
int1_route.int1_ctrl.int1_drdy_xl = 1;
997+
ism330dhcx_pin_int1_route_t int1_route;
998+
999+
retVal = ism330dhcx_pin_int1_route_get(&sfe_dev, &int1_route);
1000+
1001+
if( retVal != 0 )
1002+
return false;
1003+
1004+
int1_route.int1_ctrl.int1_drdy_xl = (uint8_t)enable;
9911005

9921006
retVal = ism330dhcx_pin_int1_route_set(&sfe_dev, &int1_route);
9931007

@@ -1004,13 +1018,19 @@ bool QwDevISM330DHCX::setAccelStatustoInt1()
10041018
// Sends the accelerometer's data ready signal to interrupt two.
10051019
//
10061020

1007-
bool QwDevISM330DHCX::setAccelStatustoInt2()
1021+
bool QwDevISM330DHCX::setAccelStatustoInt2(bool enable)
10081022
{
10091023

10101024
int32_t retVal;
10111025

10121026
ism330dhcx_pin_int2_route_t int2_route;
1013-
int2_route.int2_ctrl.int2_drdy_xl = 1;
1027+
1028+
retVal = ism330dhcx_pin_int2_route_get(&sfe_dev, &int2_route);
1029+
1030+
if( retVal != 0 )
1031+
return false;
1032+
1033+
int2_route.int2_ctrl.int2_drdy_xl = (uint8_t)enable;
10141034

10151035
retVal = ism330dhcx_pin_int2_route_set(&sfe_dev, &int2_route);
10161036

@@ -1026,13 +1046,19 @@ bool QwDevISM330DHCX::setAccelStatustoInt2()
10261046
//
10271047
// Sends the gyroscopes's data ready signal to interrupt one.
10281048
//
1029-
bool QwDevISM330DHCX::setGyroStatustoInt1()
1049+
bool QwDevISM330DHCX::setGyroStatustoInt1(bool enable)
10301050
{
10311051

10321052
int32_t retVal;
10331053

10341054
ism330dhcx_pin_int1_route_t int1_route;
1035-
int1_route.int1_ctrl.int1_drdy_g = 1;
1055+
1056+
retVal = ism330dhcx_pin_int1_route_get(&sfe_dev, &int1_route);
1057+
1058+
if( retVal != 0 )
1059+
return false;
1060+
1061+
int1_route.int1_ctrl.int1_drdy_g = (uint8_t)enable;
10361062

10371063
retVal = ism330dhcx_pin_int1_route_set(&sfe_dev, &int1_route);
10381064

@@ -1048,13 +1074,19 @@ bool QwDevISM330DHCX::setGyroStatustoInt1()
10481074
//
10491075
// Sends the gyroscopes's data ready signal to interrupt two.
10501076
//
1051-
bool QwDevISM330DHCX::setGyroStatustoInt2()
1077+
bool QwDevISM330DHCX::setGyroStatustoInt2(bool enable)
10521078
{
10531079

10541080
int32_t retVal;
10551081

10561082
ism330dhcx_pin_int2_route_t int2_route;
1057-
int2_route.int2_ctrl.int2_drdy_g = 1;
1083+
1084+
retVal = ism330dhcx_pin_int2_route_get(&sfe_dev, &int2_route);
1085+
1086+
if( retVal != 0 )
1087+
return false;
1088+
1089+
int2_route.int2_ctrl.int2_drdy_g = (uint8_t)enable;
10581090

10591091
retVal = ism330dhcx_pin_int2_route_set(&sfe_dev, &int2_route);
10601092

src/sfe_ism330dhcx.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,13 @@ class QwDevISM330DHCX
112112
bool resetTimestamp();
113113

114114
// Interrupt Settings
115-
bool setAccelStatustoInt1();
116-
bool setAccelStatustoInt2();
117-
bool setGyroStatustoInt1();
118-
bool setGyroStatustoInt2();
115+
bool setAccelStatustoInt1(bool enable = true);
116+
bool setAccelStatustoInt2(bool enable = true);
117+
bool setGyroStatustoInt1(bool enable = true);
118+
bool setGyroStatustoInt2(bool enable = true);
119119
bool setIntNotification(uint8_t val);
120120
bool setDataReadyMode(uint8_t val);
121-
bool setPinMode(bool openDrain = true);
121+
bool setPinMode(bool activeLow = true);
122122

123123
// FIFO Settings
124124
bool setFifoWatermark(uint16_t val);

0 commit comments

Comments
 (0)