Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
edspark committed Sep 15, 2022
2 parents f430202 + 1707188 commit 53062a5
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 17 deletions.
56 changes: 44 additions & 12 deletions src/sfe_ism330dhcx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -934,12 +934,20 @@ bool QwDevISM330DHCX::setFifoTimestampDec(uint8_t val)
// openDrain Set true for active low and false for active high
//

bool QwDevISM330DHCX::setPinMode(bool openDrain )
bool QwDevISM330DHCX::setPinMode(bool activeLow )
{
int32_t retVal;

//0 = push-pull, active high, 1 = open-drain, active low
retVal = ism330dhcx_pin_mode_set(&sfe_dev, (ism330dhcx_pp_od_t)openDrain);
//0 = active high : active low, 1
retVal = ism330dhcx_pin_polarity_set(&sfe_dev, (ism330dhcx_h_lactive_t)activeLow);

if( retVal != 0 )
return false;

if( activeLow )
// pinmode must be set to push-pull when active low is set.
// See section 9.14 on pg 51 of datasheet for more information
retVal = ism330dhcx_pin_mode_set(&sfe_dev, (ism330dhcx_pp_od_t)0);

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

bool QwDevISM330DHCX::setAccelStatustoInt1()
bool QwDevISM330DHCX::setAccelStatustoInt1(bool enable)
{

int32_t retVal;

ism330dhcx_pin_int1_route_t int1_route;
int1_route.int1_ctrl.int1_drdy_xl = 1;
ism330dhcx_pin_int1_route_t int1_route;

retVal = ism330dhcx_pin_int1_route_get(&sfe_dev, &int1_route);

if( retVal != 0 )
return false;

int1_route.int1_ctrl.int1_drdy_xl = (uint8_t)enable;

retVal = ism330dhcx_pin_int1_route_set(&sfe_dev, &int1_route);

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

bool QwDevISM330DHCX::setAccelStatustoInt2()
bool QwDevISM330DHCX::setAccelStatustoInt2(bool enable)
{

int32_t retVal;

ism330dhcx_pin_int2_route_t int2_route;
int2_route.int2_ctrl.int2_drdy_xl = 1;

retVal = ism330dhcx_pin_int2_route_get(&sfe_dev, &int2_route);

if( retVal != 0 )
return false;

int2_route.int2_ctrl.int2_drdy_xl = (uint8_t)enable;

retVal = ism330dhcx_pin_int2_route_set(&sfe_dev, &int2_route);

Expand All @@ -1026,13 +1046,19 @@ bool QwDevISM330DHCX::setAccelStatustoInt2()
//
// Sends the gyroscopes's data ready signal to interrupt one.
//
bool QwDevISM330DHCX::setGyroStatustoInt1()
bool QwDevISM330DHCX::setGyroStatustoInt1(bool enable)
{

int32_t retVal;

ism330dhcx_pin_int1_route_t int1_route;
int1_route.int1_ctrl.int1_drdy_g = 1;

retVal = ism330dhcx_pin_int1_route_get(&sfe_dev, &int1_route);

if( retVal != 0 )
return false;

int1_route.int1_ctrl.int1_drdy_g = (uint8_t)enable;

retVal = ism330dhcx_pin_int1_route_set(&sfe_dev, &int1_route);

Expand All @@ -1048,13 +1074,19 @@ bool QwDevISM330DHCX::setGyroStatustoInt1()
//
// Sends the gyroscopes's data ready signal to interrupt two.
//
bool QwDevISM330DHCX::setGyroStatustoInt2()
bool QwDevISM330DHCX::setGyroStatustoInt2(bool enable)
{

int32_t retVal;

ism330dhcx_pin_int2_route_t int2_route;
int2_route.int2_ctrl.int2_drdy_g = 1;

retVal = ism330dhcx_pin_int2_route_get(&sfe_dev, &int2_route);

if( retVal != 0 )
return false;

int2_route.int2_ctrl.int2_drdy_g = (uint8_t)enable;

retVal = ism330dhcx_pin_int2_route_set(&sfe_dev, &int2_route);

Expand Down
10 changes: 5 additions & 5 deletions src/sfe_ism330dhcx.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ class QwDevISM330DHCX
bool resetTimestamp();

// Interrupt Settings
bool setAccelStatustoInt1();
bool setAccelStatustoInt2();
bool setGyroStatustoInt1();
bool setGyroStatustoInt2();
bool setAccelStatustoInt1(bool enable = true);
bool setAccelStatustoInt2(bool enable = true);
bool setGyroStatustoInt1(bool enable = true);
bool setGyroStatustoInt2(bool enable = true);
bool setIntNotification(uint8_t val);
bool setDataReadyMode(uint8_t val);
bool setPinMode(bool openDrain = true);
bool setPinMode(bool activeLow = true);

// FIFO Settings
bool setFifoWatermark(uint16_t val);
Expand Down

0 comments on commit 53062a5

Please sign in to comment.