Skip to content

Commit

Permalink
Made sure exit works but still the converter can't be reset
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernd Porr committed Jan 25, 2025
1 parent 143103a commit 63f1e64
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
15 changes: 11 additions & 4 deletions LSM9DS1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,18 @@ void LSM9DS1::dataReady() {
}

void LSM9DS1::end() {
if (!running) return;
running = false;
thr.join();
gpiod_line_release(pinDRDY);
gpiod_chip_close(chipDRDY);
if (thr.joinable()) {
thr.join();
}
if (NULL != pinDRDY) {
gpiod_line_release(pinDRDY);
}
if (NULL != chipDRDY) {
gpiod_chip_close(chipDRDY);
}
pinDRDY = NULL;
chipDRDY = NULL;
}

void LSM9DS1::initGyro()
Expand Down
12 changes: 8 additions & 4 deletions LSM9DS1.h
Original file line number Diff line number Diff line change
Expand Up @@ -672,10 +672,14 @@ class LSM9DS1
running = true;
while (running) {
const struct timespec ts = { 1, 0 };
gpiod_line_event_wait(pinDRDY, &ts);
struct gpiod_line_event event;
gpiod_line_event_read(pinDRDY, &event);
dataReady();
int r = gpiod_line_event_wait(pinDRDY, &ts);
if (1 == r) {
struct gpiod_line_event event;
gpiod_line_event_read(pinDRDY, &event);
dataReady();
} else {
running = false;
}
}
}

Expand Down

0 comments on commit 63f1e64

Please sign in to comment.